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 |
back(): Interaction 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.
Examples:
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.
Examples:
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.
Examples:
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:
- BrowseTheWeb
- DeleteCookies
- Ensure
- endsWith
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:
Name | Type | Attribute | Description |
url | Answerable<string> | An absolute URL or path an Actor should navigate to |
Examples:
export const config = {
baseUrl: 'https://example.org',
// ...
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(browser))
.attemptsTo(
Navigate.to('/search'),
);
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'),
);