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 session history. |
|
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 & { withTimeout: (duration: Answerable<Duration>) => 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 session history.
Examples:
import { actorCalled } from '@serenity-js/core';
import { Ensure, endsWith } from '@serenity-js/assertions';
import { BrowseTheWeb, Navigate } from '@serenity-js/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.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/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.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/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Navigate.to('/login'),
DeleteCookies.called('session_id'),
Navigate.reloadPage(),
);
public static to(url: Answerable<string>): Interaction & { withTimeout: (duration: Answerable<Duration>) => 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, Protractor will append it to
baseUrl
configured inprotractor.conf.js
.
Params:
Name | Type | Attribute | Description |
url | Answerable<string> | An absolute URL or path an Actor should navigate to |
Returns:
Interaction & { withTimeout: (duration: Answerable<Duration>) => Interaction } |
Examples:
exports.config = {
baseUrl: 'https://example.org',
// ...
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Navigate } from '@serenity-js/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Navigate.to('/search'),
);
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Navigate } from '@serenity-js/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Navigate.to('https://mycompany.org/login'),
);
import { actorCalled, Duration } from '@serenity-js/core';
import { BrowseTheWeb, Navigate } from '@serenity-js/protractor';
actorCalled('Hannu')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Navigate.to('/search').withTimeout(Duration.ofSeconds(2)),
);
See:
- BrowseTheWeb
- @serenity-js/core~Duration