import {Navigate} from '@serenity-js/webdriverio/lib/screenplay/interactions'
public class | source

Navigate

Allows the Actor to navigate to a specific destination, as well as back and forth in the browser history, or reload the current page.

Tests:

Static Method Summary

Static Public Methods
public static

Instructs the Actor to navigate back one page in the joint session history of the current top-level browsing context.

public static

Instructs the Actor to navigate forward one page in the session history.

public static

Instructs the Actor to reload the current page.

public static

to(url: Answerable<string>): Interaction

Instructs the Actor to navigate to a given URL.

Static Public Methods

public static back(): Interaction source

Instructs the Actor to navigate back one page in the joint session history of the current top-level browsing context.

Returns:

Interaction

Examples:

Navigate to path relative to baseUrl
 import { actorCalled } from '@serenity-js/core';
 import { Ensure, endsWith } from '@serenity-js/assertions';
 import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';

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

         Navigate.back(),

         Ensure.that(Website.url(), endsWith('/first')),
     );

public static forward(): Interaction source

Instructs the Actor to navigate forward one page in the session history.

Returns:

Interaction

Examples:

Navigate to path relative to baseUrl
 import { actorCalled } from '@serenity-js/core';
 import { Ensure, endsWith } from '@serenity-js/assertions';
 import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';

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

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

         Ensure.that(Website.url(), endsWith('/second')),
     );

public static reloadPage(): Interaction source

Instructs the Actor to reload the current page.

Returns:

Interaction

Examples:

Navigate to path relative to baseUrl
 import { actorCalled } from '@serenity-js/core';
 import { Ensure, endsWith } from '@serenity-js/assertions';
 import { Navigate, BrowseTheWeb, DeleteCookies } from '@serenity-js/webdriverio';

 actorCalled('Hannu')
     .whoCan(BrowseTheWeb.using(browser))
     .attemptsTo(
         Navigate.to('/login'),
         DeleteCookies.called('session_id'),
         Navigate.reloadPage(),
     );

See:

public static to(url: Answerable<string>): Interaction source

Instructs the Actor to navigate to a given URL.

The URL can be:

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

    If the URL is relative, WebdriverIO will append it to baseUrl specified in the configuration file.

Params:

NameTypeAttributeDescription
url Answerable<string>

An absolute URL or path an Actor should navigate to

Returns:

Interaction

Examples:

wdio.conf.ts
 export const config = {
     baseUrl: 'https://example.org',
     // ...
 }
Navigate to path relative to baseUrl
 import { actorCalled } from '@serenity-js/core';
 import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';

 actorCalled('Hannu')
     .whoCan(BrowseTheWeb.using(browser))
     .attemptsTo(
         Navigate.to('/search'),
     );
Navigate to an absolute URL (overrides baseUrl)
 import { actorCalled } from '@serenity-js/core';
 import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';

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