Optional
aliasName with which the ability is identified internally on actor level.
Static
usingInitialize this Ability by passing an already existing Playwright Page object.
the Playwright Page that will be used to browse.
Returns the ability to use a browser
Static
asUse this Ability as an Actor. Required by Actions to get access to the ability functions.
Actor is using this ability
Optional
alias: stringReturns the ability to use a browser
Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be obtained via BrowseTheWeb.getCookies([urls]).
Cookies to add at browser context
Returns after adding cookies into this browser context.
await BrowseTheWeb.as(actor).addCookies([{
name: 'my cookie',
value: 'my value',
url: 'http://www.myapp.com',
}]);
Get the cookies of the current browser context. If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs are returned.
Optional
urls: string | string[]affected urls
Returns the cookies of the current browser context.
get all cookies
await BrowseTheWeb.as(actor).getCookies();
get cookies for one single domain
await BrowseTheWeb.as(actor).getCookies('https://example.com');
get cookies for two domains
await BrowseTheWeb.as(actor).getCookies(['https://example.com', 'https://www.com']);
Delete a local storage item, if a key/value pair with the given key exists.
the key that specifies the item.
Returns after deleting a local storage item
await BrowseTheWeb.as(actor).removeLocalStorageItem('some key');
Delete a session storage item, if a key/value pair with the given key exists.
the key that specifies the item.
Returns after removing a session storage item.
await BrowseTheWeb.as(actor).removeSessionStorageItem('some key');
Save storage state for this browser context, contains current cookies and local storage snapshot.
The file path to save the storage state to.
Returns storage state.
await BrowseTheWeb.as(actor).removeSessionStorageItem('some key');
Set a local storage item identified by the given key + value, creating a new key/value pair if none existed for key previously.
the key that specifies the item.
the value to set.
Returns after adding the local storage item
await BrowseTheWeb.as(actor).setLocalStorageItem('some key', 'some value');
Set a session storage item identified by the given key + value, creating a new key/value pair if none existed for key previously.
the key that specifies the item.
the value to set.
Set the session storage item
await BrowseTheWeb.as(actor).setSessionStorageItem('some key', 'some value');
Verify if the given element is checked.
the locator of the element.
whether to check the property of the locator positive or not.
Optional
options: { Optional
checked?: booleanOptional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element is checked/not as expected, false if the timeout was reached.
Verify if a locator on the page is editable or not.
the locator to search for.
whether to check the state of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
editable?: booleanOptional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element is editable/not as expected, false if the timeout was reached.
simple call with just locator
await BrowseTheWeb.as(actor).checkEditableState(
page.locator('myLocator'),
true
);
with options
await BrowseTheWeb.as(actor).checkEditableState(
page.locator('myLocator'),
false,
{ timeout: 1000 }
);
Verify if a locator on the page is enabled or disabled.
the locator to search for.
whether to check the state of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
enabled?: booleanOptional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element is enabled/disabled as expected, false if the timeout was reached.
simple call with just locator
await BrowseTheWeb.as(actor).checkEnabledState(
page.locator('myLocator'),
true
);
with options
await BrowseTheWeb.as(actor).checkEnabledState(
page.locator('myLocator'),
false,
{ timeout: 1000 }
);
Verify if a locator on the page is focused or not.
the locator to search for.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element is editable/not as expected, false if the timeout was reached.
simple call with just locator
await BrowseTheWeb.as(actor).checkFocusedState(
page.locator('myLocator'),
true
);
with options
await BrowseTheWeb.as(actor).checkFocusedState(
page.locator('myLocator'),
false,
{ timeout: 1000 }
);
Verify if the given element contains the given text or not.
the locator of the element to hover over.
the text to check.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
ignoreWhether to perform case-insensitive match. ignoreCase
option takes precedence over the corresponding regular
expression flag if specified.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
Optional
useWhether to use element.innerText
instead of element.textContent
when retrieving DOM node text.
Verify if the given element has the given CSS or not.
the locator of the element to hover over.
the style name and value to check.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element has CSS/not as expected, false if the timeout was reached.
Verify if the element has exact number of DOM node.
the locator of the element.
the minimum count of the element to be visible.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element has exact number of DOM node, false if the timeout was reached.
Verify if the given element has the given screenshot or not.
the locator of the element to hover over.
the screenshot name.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
animations?: "disabled" | "allow"When set to "disabled"
, stops CSS animations, CSS transitions and Web Animations. Animations get different
treatment depending on their duration:
transitionend
event.Defaults to "disabled"
that disables animations.
Optional
caret?: "hide" | "initial"When set to "hide"
, screenshot will hide text caret. When set to "initial"
, text caret behavior will not be
changed. Defaults to "hide"
.
Optional
mask?: Locator[]Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink
box #FF00FF
(customized by maskColor
) that completely covers its bounding box.
Optional
maskSpecify the color of the overlay box for masked elements, in
CSS color format. Default color is pink #FF00FF
.
Optional
maxAn acceptable ratio of pixels that are different to the total amount of pixels, between 0
and 1
. Default is
configurable with TestConfig.expect
. Unset by default.
Optional
maxAn acceptable amount of pixels that could be different. Default is configurable with TestConfig.expect
. Unset by
default.
Optional
omitHides default white background and allows capturing screenshots with transparency. Not applicable to jpeg
images.
Defaults to false
.
Optional
scale?: "css" | "device"When set to "css"
, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this
will keep screenshots small. Using "device"
option will produce a single pixel per each device pixel, so
screenshots of high-dpi devices will be twice as large or even larger.
Defaults to "css"
.
Optional
threshold?: numberAn acceptable perceived color difference in the YIQ color space between the
same pixel in compared images, between zero (strict) and one (lax), default is configurable with
TestConfig.expect
. Defaults to 0.2
.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element has screenshot/not as expected, false if the timeout was reached.
Verify if the given element has the given text or not.
the locator of the element to hover over.
the text to check.
whether to check the property of the locator positive or not.
Optional
options: { options for assertion.
Optional
ignoreWhether to perform case-insensitive match. ignoreCase
option takes precedence over the corresponding regular
expression flag if specified.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
Optional
useWhether to use element.innerText
instead of element.textContent
when retrieving DOM node text.
true if the element has text/not as expected, false if the timeout was reached.
Verify if the given element has the given input value or not.
the locator of the element to hover over.
the single value to check.
whether to check the property of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
true if the element has value/not as expected, false if the timeout was reached.
Verify if the page has specified title.
whether to check the property of the page positive or not.
the screenshot name
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberOptional
page: Page(optional) the playwright page object to verify.
Promise
Verify if the page has specified title.
whether to check the property of the page positive or not.
the expected title of the page.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberOptional
page: Page(optional) the playwright page object to verify.
Promise
Verify if the page has specified URL.
whether to check the property of the page positive or not.
the expected url of the page.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberOptional
page: Page(optional) the playwright page object to verify.
Promise
Verify if a locator on the page is visible or hidden.
the locator to search for.
whether to check the visibility of the locator positive or not.
Optional
options: { (optional) options for assertion.
Optional
timeout?: numberTime to retry the assertion for in milliseconds. Defaults to timeout
in TestConfig.expect
.
Optional
visible?: booleanPromise
simple call with just locator
await BrowseTheWeb.as(actor).checkVisibilityState(
page.locator('myLocator'),
true
);
with options
await BrowseTheWeb.as(actor).checkVisibilityState(
page.locator('myLocator'),
false,
{ timeout: 1000 }
);
Check the specified checkbox.
the locator of the checkbox.
Optional
options: CheckActionOptions(optional) options for interaction.
Returns after checking the element
simple call with just locator
await BrowseTheWeb.as(actor).checkBox(page.locator('myLocator'));
call with options
await BrowseTheWeb.as(actor)
.checkBox(
page.locator('myLocator'),
{ timeout: 1000 }
);
Click the element specified by the locator.
the locator of the element to click.
Optional
options: ClickActionOptions(optional) options for interaction.
Returns after clicking the element
simple call with just locator
await BrowseTheWeb.as(actor).click(
page.locator('myLocator')
);
with options
await BrowseTheWeb.as(actor).click(
page.locator('myLocator'),
{ timeout: 1000 }
);
Double click the element specified by the locator.
the locator of the element to double click.
Optional
options: DblclickActionOptions(optional) options for interaction.
Returns after double clicking the element
simple call with just locator
await BrowseTheWeb.as(actor).dblclick(
page.locator('myLocator')
);
with options
await BrowseTheWeb.as(actor).dblclick(
page.locator('myLocator'),
{ timeout: 1000 }
);
Drag the specified source element to the specified target element and drop it.
the locator of the source element.
the locator of the target element.
Optional
options: DragAndDropActionOptions(optional) options for interaction.
Returns after dragging the locator to another target locator or target position
simple call with just source and target locator
await BrowseTheWeb.as(actor).dragAndDrop(
page.locator('sourceLocator'),
page.locator('targetLocator')
);
with options
await BrowseTheWeb.as(actor).dragAndDrop(
page.locator('sourceLocator'),
page.locator('targetLocator'),
{ timeout: 1000 }
);
Fill the element specified by the locator with the given input.
the locator of the source element.
the input to fill the element with.
Optional
options: FillActionOptions(optional) options for interaction.
Returns after checks, focuses the element, fills it and triggers an input
event after filling.
simple call with just locator and input value
await BrowseTheWeb.as(actor).fill(
page.locator('myLocator'),
'myInput'
);
with options
await BrowseTheWeb.as(actor).fill(
page.locator('myLocator'),
'myInput',
{ timeout: 1000 }
);
Focus the element specified by the locator.
the locator of the element to focus.
Optional
options: { (optional) options for interaction.
Optional
timeout?: numberReturns after focus the element
simple call with just locator
await BrowseTheWeb.as(actor).focus(
page.locator('myLocator')
);
with options
await BrowseTheWeb.as(actor).focus(
page.locator('myLocator'),
{ timeout: 1000 }
);
Use the page to navigate to the specified URL.
the url to access.
Optional
options: NavigateActionOptions(optional) options for interaction.
Returns the main resource response
await BrowseTheWeb.as(actor).goto('myURL');
Use the page mouse to hover over the specified element.
Optional
options: HoverActionOptions(optional) options for interaction.
Returns when hovered over the element
simple call with just locator
await BrowseTheWeb.as(actor).hover(page.locator("myLocator"));
with options
await BrowseTheWeb.as(actor).hover(page.locator("myLocator"), {
modifiers: ['Alt', 'Shift']
});
Press the specified key(s) on the keyboard.
the key(s). multiple keys can be pressed by concatenating with "+"
Optional
options: PressActionOptions(optional) options for interaction.
Returns when the key
can specify the intended value or a single character to generate the text for.
Press a single button
await BrowseTheWeb.as(actor).press('A');
Press multiple buttons
await BrowseTheWeb.as(actor).press('Control+A');
Press the specified keys sequentially for each string character. To press a special key, like Control or ArrowDown, use press.
the locator of the source element.
string of characters to sequentially press into a focused element
Optional
options: PressActionOptions(optional) options for interaction.
Returns when the keys
can specify the intended values or characters to generate the text for.
simple call with just locator and input value
await BrowseTheWeb.as(actor).pressSequentially('ABC');
Reload the current page.
Optional
options: ReloadActionOptions(optional) options for interaction.
Returns the main resource response
await BrowseTheWeb.as(actor).reload();
Set the value of a Locator of type select to the given option.
the string representing the (select) locator.
options to select.
Optional
options: SelectActionOptions(optional) options for interaction.
Returns the array of option values that have been successfully selected.
simple call with just locator and input value
await BrowseTheWeb.as(actor).selectOption(
page.locator('myLocator'),
'myOptionLabel'
);
with options
await BrowseTheWeb.as(actor).selectOption(
page.locator('myLocator'),
'myOptionLabel'
{ timeout: 1000 }
);
Type the given input into the element specified by the locator.
the locator of the source element.
the input to type into the element.
Optional
options: TypeActionOptions(optional) options for interaction.
Focuses the element, and then sends a keydown
, keypress
/input
, and keyup
event for each character in the text.
In most cases, you should use fill instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use pressSequentially.
simple call with just locator and input value
await BrowseTheWeb.as(actor).type(
page.locator('myLocator'),
'myInput'
);
with options
await BrowseTheWeb.as(actor).type(
page.locator('myLocator'),
'myInput',
{ timeout: 1000 }
);
Wait for the specified event in browser.
the event in browser to wait for.
Optional
options: WaitForEventActionOptions<Page | Response | BrowserContext | ConsoleMessage | Dialog | Request | WebError | Worker>(optional) options for interaction.
Returns the event data value.
await BrowseTheWeb.as(actor).waitForEvent('page');
Wait for the specified event on page.
the event on page to wait for.
Optional
options: WaitForEventActionOptions<Error | Page | Response | ConsoleMessage | Dialog | Request | Worker | Download | FileChooser | Frame | WebSocket>(optional) options for interaction.
Returns the event data value.
await BrowseTheWeb.as(actor).waitForEventOnPage('console');
Wait for the specified loading state.
the status to wait for. Allowed: "load" | "domcontentloaded" | "networkidle".
Optional
options: WaitForLoadStateActionOptions(optional) options for interaction.
Returns when the required load state has been reached.
await BrowseTheWeb.as(actor).waitForLoadState('networkidle');
Wait until the element of the specified locator exists.
the locator of the element.
Optional
options: WaitForLocatorActionOptions(optional) options for interaction.
Returns when the element exists
simple call with just locator
await BrowseTheWeb.as(actor).waitForLocator(
page.locator('myLocator')
);
with options
await BrowseTheWeb.as(actor).waitForLocator(
page.locator('myLocator'),
{ state: "visible" }
);
Wait for the specified URL.
the url to wait for.
Optional
options: WaitForUrlActionOptions(optional) options for interaction.
Returns when the page specified url has been reached.
await BrowseTheWeb.as(actor).waitForUrl('example.com');
Generated using TypeDoc
This class represents the actor's ability to use a Browser. This ability enables the actor to interact with the browser and browse web user interfaces.