Skip to main content

Navigate

Instructs an actor who has the ability to BrowseTheWeb to navigate to a specific destination, as well as back and forth in the browser history, or reload the current page.

Learn more

Index

Constructors

constructor

Methods

staticto

  • to(url: Answerable<string>): Interaction
  • Instructs an actor who has the ability to BrowseTheWeb to navigate to a given URL.

    The URL can be:

    • absolute, e.g. https://example.org/search
    • relative, e.g. /search

    If the URL is relative, your Web test integration tool will append it to any base URL specified in its respective configuration file.

    Navigate to path relative to baseUrl

    import { actorCalled } from '@serenity-js/core'
    import { Navigate } from '@serenity-js/web'

    await actorCalled('Hannu')
    .attemptsTo(
    Navigate.to('/search'),
    )

    Navigate to an absolute URL (overrides baseUrl)

    import { actorCalled } from '@serenity-js/core'
    import { Navigate } from '@serenity-js/web'

    await actorCalled('Hannu')
    .whoCan(BrowseTheWeb.using(browser))
    .attemptsTo(
    Navigate.to('https://mycompany.org/login'),
    )

    Learn more


    Parameters

    • url: Answerable<string>

      An absolute URL or path an Actor should navigate to

    Returns Interaction

staticback

  • back(): Interaction
  • Instructs an actor who has the ability to BrowseTheWeb to navigate back one page in the joint session history of the current top-level browsing context.

    Navigate back in browsing history

    import { actorCalled } from '@serenity-js/core'
    import { Ensure, endsWith } from '@serenity-js/assertions'
    import { Navigate, Page } from '@serenity-js/web'

    await actorCalled('Hannu')
    .whoCan(BrowseTheWeb.using(browser))
    .attemptsTo(
    Navigate.to('/first'),
    Navigate.to('/second'),

    Navigate.back(),

    Ensure.that(Page.current().url().href, endsWith('/first')),
    )

    Returns Interaction

staticforward

  • forward(): Interaction
  • Instructs an actor who has the ability to BrowseTheWeb to navigate forward one page in the joint session history of the current top-level browsing context.

    Navigate forward in browsing history

    import { actorCalled } from '@serenity-js/core'
    import { Ensure, endsWith } from '@serenity-js/assertions'
    import { Navigate, Page } from '@serenity-js/web'

    await actorCalled('Hannu')
    .whoCan(BrowseTheWeb.using(browser))
    .attemptsTo(
    Navigate.to('/first'),
    Navigate.to('/second'),

    Navigate.back(),
    Navigate.forward(),

    Ensure.that(Page.current().url().href, endsWith('/second')),
    )

    Returns Interaction

staticreloadPage

  • reloadPage(): Interaction
  • Instructs an actor who has the ability to BrowseTheWeb to reload the current page.

    Navigate to path relative to baseUrl

    import { actorCalled } from '@serenity-js/core'
    import { Ensure, endsWith } from '@serenity-js/assertions'
    import { Navigate, Cookie } from '@serenity-js/web'
    import { browser } from '@wdio/globals'

    await actorCalled('Hannu')
    .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
    .attemptsTo(
    Navigate.to('/login'),
    Cookie.called('session_id').delete(),
    Navigate.reloadPage(),
    )

    Returns Interaction