The plugin provides functionality to interact with Web applications.
plugins:partial$plugin-web-app-locators.adoc
Note
|
The properties marked with bold are mandatory. |
Property Name | Acceptable values | Default | Description |
---|---|---|---|
|
Valid target platform name |
empty |
Identifies the operating system for the testing. e.g. |
|
Valid target platform version |
empty |
Identifies the operating system version for the testing. e.g. partial$selenium-properties.adoc partial$proxy-properties.adoc |
|
|
|
Provides possibility to attach screenshot for failed proxy steps |
|
string with arguments |
|
|
|
header size as a viewport size percent |
|
Before the click VIVIDUS scrolls element into the viewport, the property defines top edge indent in viewport percent for the scroll |
In addition to the command line arguments, user preferences (see the Preferences file in Chrome’s user data directory or open chrome://prefs-internals/
link in Chrome browser for examples) can be customised.
Here is an example how to configure third-party cookies behaviour.
web.driver.CHROME.experimental-options={"prefs": {"profile": {"cookie_controls_mode": 0}}}
The allowed values for the preference from the example are:
-
0
- allow all cookies; -
1
- block third-party cookies; -
2
- block third-party cookies in Incognito mode only.
The set of dynamic variables provides ability to access height and width of the browser window.
Variable name | Description |
---|---|
|
the height of the browser window |
|
the width of the browser window |
When I change window size to `800x600`
Then `${browser-window-width}` is = `800`
Then `${browser-window-height}` is = `600`
plugins:partial$plugin-web-app-profiles.adoc
plugins:partial$plugin-web-app-steps.adoc
Waits for the windows with desired title and switches to it.
When I wait `$duration` until window with title that $comparisonRule `$windowTitile` appears and switch to it
-
$duration
- The timeout duration to wait for a window in {iso-date-format-link} format. -
$comparisonRule
- The window title comparison rule. -
$windowTitle
- The expected window title.
Given I am on a page with the URL 'https://vividus-test-site.onrender.com/windows.html'
When I click on element located by `id(timeout)`
When I wait `PT3S` until window with title that is equal to `Vividus test site` appears and switch to it
Stops page loading
When I stop page loading
Tip
|
Could be useful in combination with Selenium’s page load strategy |
When I open URL `https://delayed.vividus.dev` in new window
When I stop page loading
Sets a custom page load timeout for a part of the story
When I set page load timeout to `$duration`
-
$duration
- total duration to wait for page load completion in {iso-date-format-link} format
Given I am on a page with the URL 'https://example.com/'
When I set page load timeout to `PT20S`
When I open URL `https://example.com/super-heavy-page` in new window
When I set page load timeout to `PT10S`
Checks web performance metrics.
Then metric $webPerformanceMetric is $comparisonRule `$duration`
-
$webPerformanceMetric
- The web performance metric. Where:-
TIME_TO_FIRST_BYTE
- The time between the navigation start and the response start. -
DNS_LOOKUP_TIME
- The time between the domain lookup start and the domain lookup end. -
DOM_CONTENT_LOAD_TIME
- The time between the DOM loading and the the DOM complete. -
PAGE_LOAD_TIME
- The time between the navgation start and the load event end.
-
-
$comparisonRule
- The duration comparison rule. -
$duration
- The duration to compare against in {iso-date-format-link} format.
Given I am on a page with the URL 'https://example.com'
Then metric PAGE_LOAD_TIME is less than `PT5S`
Scan a barcode from the specified context and save its value to the variable with the specified name. If context not set - takes a screenshot of the entire page. Only the first found barcode will be scanned.
Supported Code Formats
Actions performed at this step:
-
Takes a screenshot of the specified context. If it’s not set - takes a screenshot of the entire page
-
Scans a barcode from the screenshot and save its value to the variable
When I scan barcode from context and save result to $scopes variable `$variableName`
-
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The name of the variable to save the value of the barcode.
When I change context to element located `By.xpath(//div[@id='qrCode'])`
When I scan barcode from context and save result to scenario variable `qrCodeLink`
Then `${qrCodeLink}` is equal to `https://www.example.com`
Fields are elements where users can enter data. The most typical fields are:
Enters the text in a field found by the specified locator.
The atomic actions performed are:
-
find the field by the locator;
-
clear the field if it is found, otherwise the whole step is failed and its execution stops;
-
type the text in the field;
-
the first three actions are retried once if the field becomes stale during actions execution in other words if StaleElementReferenceException is thrown at any atomic action.
When I enter `$text` in field located by `$locator`
-
$text
- The text to enter in the field. -
$locator
- The locator used to find field.
When I enter `pa$$w0rd` in field located by `id(password)`
Enters the text in the field found by the specified locator without clearing of the previous content.
When I add `$text` to field located by `$locator`
-
$text
- The text to add to the field. -
$locator
- The locator used to find field.
When I add `name` to field located by `id(username)`
Clears the field found by the specified locator. The step does not trigger any keyboard or mouse events on the field.
When I clear field located by `$locator`
-
$locator
- The locator used to find field.
When I clear field located by `id(username)`
Clears the field found by the specified locator using keyboard. The step simulates user action by pressing buttons kbd:[Ctrl+A] and then kbd:[Backspace] that allows to trigger keyboard events on the field.
When I clear field located by `$locator` using keyboard
-
$locator
- The locator used to find field.
When I clear field located by `id(password)` using keyboard
Validates whether the dropdown located by locator exists and contains the list of the expected options.
Then dropdown located `$locator` contains options: $option
-
$locator
- The locator used to find dropdown. -
$options
- examples table describing expected options
Then a drop down with the name 'colors' contains the items:
|state|item |
|false|Red |
|false|Green|
|true |Blue |
Important
|
The item is an option. The state (true or false ) specifies whether the item is selected.
|
Verifies if dropdown located by locator exists and first selected option.
Then dropdown located `$locator` exists and selected option is `$option`
-
$locator
- The locator used to find dropdown. -
$option
- first selected option
Then dropdown located `id(colors)` exists and selected option is `Blue`
Selects option in multi-select dropdown
Important
|
Step will fail if target dropdown is not multi-select |
When I add `$option` to selection in dropdown located `$locator`
-
$option
- option to select -
$locator
- The locator used to find dropdown.
When I add `Two` to selection in dropdown located `id(numbers)`
Selects option in dropdown
Important
|
Does not support multi-selection |
When I select `$option` in dropdown located `$locator``
-
$option
- option to select -
$locator
- The locator used to find dropdown.
When I select `Red` in dropdown located `id(colors)`
Validates whether the certain cookie is set.
Then cookie with name `$cookieName` is set
-
$cookieName
- The name of the cookie to check presence.
Then cookie with name `JSESSIONID` is set
Validates whether the certain cookie is not set.
Then cookie with name `$cookieName` is not set
-
$cookieName
- The name of the cookie to check absence.
Then cookie with name `JSESSIONID` is not set
Adds the cookies provided in the input ExamplesTable. It’s allowed to add the cookies for the current domain only: make sure the web browser is opened at the expected domain. The actions performed by the step:
-
add the cookies;
-
refresh the current page (this action is required to apply the changes in cookies).
When I set all cookies for current domain:$parameters
-
$parameters
- The parameters of the cookies to set as ExamplesTable:Column Name Description cookieName
the name of the cookie to set
cookieValue
the value of the cookie to set
path
the path of the cookie to set
When I set all cookies for current domain:
|cookieName |cookieValue |path |
|cookieAgreed |2 |/ |
Finds the cookie by the name and saves its value to a variable.
When I save value of cookie with name `$cookieName` to $scopes variable `$variableName`
-
$cookieName
- The name of the cookie to save the value. -
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The variable name to save the cookie value.
When I save value of cookie with name `JSESSIONID` to scenario variable `session-id`
Finds the cookie by the name and saves all its parameters as JSON to a variable.
When I save cookie with name `$cookieName` as JSON to $scopes variable `$variableName`
-
$cookieName
- The name of the cookie to save. -
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The variable name to save the cookie.
When I save cookie with name `JSESSIONID` as JSON to scenario variable `session-id`
Removes the certain cookie from the current domain. The actions performed by the step:
-
remove the certain cookie the from current domain;
-
refresh the current page (this action is required to apply the changes in cookies).
When I remove cookie with name `$cookieName` from current domain
-
$cookieName
- The name of the cookie to remove.
When I remove cookie with name `JSESSIONID` from current domain
Removes the certain cookie from the current domain, but does not apply the changes in cookies. The current page must be refreshed or the navigation must be performed to apply the cookie changes.
When I remove cookie with name `$cookieName` from current domain without applying changes
-
$cookieName
- The name of the cookie to remove.
When I remove cookie with name `JSESSIONID` from current domain without applying changes
When I refresh the page
Removes all cookies from the current domain. The actions performed by the step:
-
remove all cookies from the current domain;
-
refresh the current page (this action is required to apply the changes in cookies).
When I remove all cookies from current domain
Web Storage steps
Finds the web storage item by the key and saves its value to the variable.
When I save $storageType storage item with key `$key` to $scopes variable `$variableName`
-
$storageType
- One of the web storage mechanisms: eitherlocal
orsession
. -
$key
- The name of the key to retrieve the value of. -
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The name of the variable to store the value of the web storage item.
When I save local storage item with key `token` to scenario variable `application-token`
Adds the item with the specified key-value pair to the web storage, or updates that key’s value if it already exists.
When I set $storageType storage item with key `$key` and value `$value`
-
$storageType
- One of the web storage mechanisms: eitherlocal
orsession
. -
$key
- The name of the key to create/update. -
$value
- The value to give the key that is creating/updating.
When I set session storage item with key `token` and value `session-token`
Validates the web storage item with the specified key exists.
Then $storageType storage item with key `$key` exists
-
$storageType
- One of the web storage mechanisms: eitherlocal
orsession
. -
$key
- The name of the key to check presence.
Then session storage item with key `token` exists
Validates the web storage item with the specified key does not exist.
Then $storageType storage item with key `$key` does not exist
-
$storageType
- One of the web storage mechanisms: eitherlocal
orsession
. -
$key
- The key of the local storage item to check absence.
Then local storage item with key `token` does not exist
Changes the current browser window size to the specified one.
Important
|
The specified browser window size should be smaller than the current screen resolution. |
When I change window size to `$targetSize`
-
$targetSize
- The desired browser window size in pixels, e.g.800x600
, where the first measure is window width, the last one is window height.
Given I am on a page with the URL 'https://example.com/'
When I change window size to `640x320`
Steps allow to interact with video elements.
Starts video playback.
When I play video in video player located `$locator`
-
$locator
- The locator used to find video player.
Pauses video playback.
When I pause video in video player located `$locator`
-
$locator
- The locator used to find video player.
Rewinds video to the desired mark in seconds.
When I rewind time to `$number` seconds in video player located `$locator`
-
$number
- time mark in seconds -
$locator
- The locator used to find video player.
Saves video player info: duration, currentTime, src, networkState. For more information about the properties see HTML Audio/Video Properties
When I save info from video player located `$locator` to $scopes variable `$variableName`
-
$locator
- The locator used to find video player. -
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The variable name to save the info. If the variable name is info, the following variables will be created:-
${info.src}
- The current source of the audio/video element -
${info.duration}
- The length of the current audio/video (in seconds) -
${info.currentTime}
- The current playback position in the audio/video(in seconds) -
${info.networkState}
- The current network state of the audio/video. For more information see: Network State
-
Given I am on a page with the URL 'https://www.youtube.com/watch?v=pYqyVpCV-3c'
When I pause video in video player located `cssSelector(video)`
When I rewind time to `777` seconds in video player located `cssSelector(video)`
When I play video in video player located `cssSelector(video)`
When I save info from video player located `cssSelector(video)` to SCENARIO variable `info`
Then `${info.currentTime}` is > `0`
Then `${info.duration}` is > `1000`
Then `${info.networkState}` is = `2`
Then `${info.src}` matches `.+youtube.+`
Allows to set command line arguments for browsers. This step works similar to the property
web.driver.<browser-name>.command-line-arguments
In case both property and step are used - arguments from property will be ignored. Step will take effect for all new browser sessions created in the current story. It will not affect the current sessions.
List of supported command line arguments for popular browsers: . Chrome . Firefox . Internet Explorer
Not supported browsers: . Safari . Edge
When I set browser command line arguments to `$argsString`
-
$argsString
- Sequence of command line arguments, separated by space.
When I set browser command line arguments to `--use-fake-ui-for-media-stream --use-file-for-fake-video-capture=${videoStorage}/${video1}.y4m --use-fake-device-for-media-stream`
Given I am on the main application page
Executes async JavaScript code and saves result into variable.
When I execute async javascript `$jsCode` and save result to $scopes variable `$variableName`
-
$jsCode
- Any JavaScript code. In order to save a result return statement should be used. -
$scopes
- The comma-separated set of the variables scopes. -
$variableName
- The variable name to save the cookie value.
When I execute async javascript `
var callback = arguments[arguments.length - 1];
var xhr = new XMLHttpRequest();
xhr.open('GET', '/resource/data.json', true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
callback(xhr.responseText);
}
};
xhr.send();` and save result to scenario variable `response`
Then `${response}` matcher `.+`
Warning
|
The step is deprecated and will be removed in VIVIDUS 0.6.0. The replacement is a generic step waiting for element disappearance. |
Waits for an element with the specified tag, attribute type and value disappearance.
Actions performed by step:
-
Searches for an element with the specified attribute and tag within search context
-
If there are no elements by specified attribute and tag, step provides passed assertion and don’t check disappearance of an element
-
If there are elements by specified attribute and tag, waits until this element becomes not visible
Note
|
If the element doesn’t exist on the page/context, the step will immediately complete successfully. Checking the element on the page (if needed) should be done in a separate step (e.g. [_wait_for_element_appearance] or Validate elements). |
When I wait until an element with the tag '$elementTag' and attribute '$attributeType'='$attributeValue' disappears
-
$elementTag
- Type of the html tag (e.g.div
oriframe
). -
$attributeType
- Type of the tag attribute (e.g.name
orid
). -
$attributeValue
- Value of the attribute.
div
element with a certain attribute and valueWhen I click on a button with the name 'Toggle element visibility with delay'
When I wait until an element with the tag 'div' and attribute 'id'='delayed' disappears
Waits for element disappearance with desired timeout.
Note
|
If the element doesn’t exist on the page/context, the step will immediately complete successfully. Checking the element on the page (if needed) should be done in a separate step (e.g. [_wait_for_element_appearance] or Validate elements). |
Then element located by `$locator` disappears in `$timeout`
Deprecated syntax (will be removed in VIVIDUS 0.6.0):
Then element located '$locator' disappears in '$timeout'
-
$locator
- The locator used to element. -
$timeout
- The maximum time to wait for the element disappearance in {iso-date-format-link} format.
When I click on a button with the name 'Toggle element visibility with delay'
Then element located 'By.xpath(//div[@id='delayed'])' disappears in 'PT3S'