Web Application Plugin
The plugin provides functionality to interact with Web applications.
Installation
-
Copy the below line to
dependencies
section of the projectbuild.gradle
fileExample 1. build.gradleimplementation(group: 'org.vividus', name: 'vividus-plugin-web-app', version: '0.5.5')
-
If the project was imported to the IDE before adding new plugin, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.
Locator
By.<locatorType>(<locatorValue>):<visibility>->filter.<filterType>(<filterValue>)
By. prefix is optional. |
-
locatorType
- [mandatory] type of the locator -
locatorValue
- [mandatory] value of the locator -
visibility
- [optional] visibility of element (visible by default) -
filterType
- [optional] type of the filter -
filterValue
- [required if filter type defined] value of the filter
Reusable locators
Feature allows to define custom reusable locator types via properties. These new locator types should rely on one of the already existing ones.
ui.locator.<locatorName>.pattern
ui.locator.<locatorName>.locator-type
-
locatorName
- The name of the reusable locator. Supported characters areA-Z, a-z, -
. -
pattern
- The pattern of the reusable locator. -
locator-type
- The base locator type.
ui.locator.anyAttOrText.locator-type=xpath
ui.locator.anyAttOrText.pattern=//*[@*='%s' or text()='%s']
Given I am on main application page
Then number of elements found by `anyAttOrText(attribute, text)` is = `1`
Given I am on main application page
Then number of elements found by `anyAttOrText(attribute, with comma\, text)` is = `1`
Description | Pattern | Usage | Result |
---|---|---|---|
Single parameter doesn’t require comma escaping. |
|
|
|
The pattern with a single parameter was referenced twice. |
|
|
|
The pattern with a |
|
|
|
The pattern containing |
|
|
|
The pattern without parameters |
|
|
|
The pattern with two parameter placeholders was used with invalid number of parameters. |
|
|
|
Locator Types
Type | Description | Example |
---|---|---|
|
id attribute of an element |
id(submitForm) |
|
CSS selector to an element |
cssSelector(.menu-item) |
|
xpath(//a) |
|
|
name of an element tagName |
tagName(a) |
|
CSS class name |
className(bold) |
|
text of the link |
linkText(Google) |
|
href attribute of the link element |
linkUrl(/faq) |
|
part of a href attribute of the link element |
linkUrlPart(faq) |
|
case sensitive text of an element |
caseSensitiveText(Description) |
|
case insensitive text of an element |
caseInsensitiveText(description) |
|
shortcut to a .//img[@src='<value>>'] |
imgSrc(/images/kote.png) |
|
shortcut to a .//img[contains(@src,'<value>>')]'] |
imgSrcPart(kote.png) |
|
elements of type button or input with text or any attribute value |
buttonName(submit) |
|
input or textarea with text or any attribute value |
fieldName(editor) |
|
input element with @type="checkbox" and text value |
checkboxName(allow) |
|
any attribute or text value |
elementName(OK) |
|
chain of css selectors, separated by |
shadowCssSelector(.upperHost; #innerHost1; #innerHost2; .targetValue) |
Visibility types
Visibility type | Usage example | Description |
---|---|---|
VISIBLE |
xpath(//a) |
Default visibility option. Only visible elements will be found |
INVISIBLE |
xpath(//a):i |
Only invisible elements will be found |
all |
xpath(//a):a |
Either visible and invisible elements will be found |
Filter types
The filters are applied after elements search using one of the locators specified above. The elements not matching the filter condition are sorted out without any notice.
Filter type | Description | Example |
---|---|---|
|
Get an element by the specified index from a collection of elements found by a locator. Indexes start from 1. |
tagName(div)→filter.index(2) |
|
Filter elements by their text parts. |
tagName(h3)→filter.textPart(Welcome) |
|
element State |
id(v1)→filter.state(VISIBLE) |
|
element text should match case sensitively |
id(v1)→filter.caseSensitiveText(text) |
|
class attribute should contain part |
id(v1)→filter.classAttributePart(clazz) |
|
href attribute of the link element |
id(v1)→filter.linkUrl(/url) |
|
part of href attribute of the link element |
id(v1)→filter.linkUrlPart(/url) |
|
title attribute value |
id(v1)→filter.tooltip(title) |
|
src attribute should contain value |
id(v1)→filter.imageSrcPart(part) |
|
Placeholder attribute should be equal to a value |
id(v1)→filter.placeholder(placeholder-value) |
|
CSS property background-image should match |
id(v1)→filter.validationIconSource(src) |
|
field text should match expected value |
id(v1)→filter.fieldText(value) |
|
field text should contain expected value |
id(v1)→filter.fieldTextPart(value) |
|
any of select options should be equal to a value |
id(v1)→filter.dropDownText(value) |
Properties
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. |
|
|
|
The test lifecycle of the browser:
An empty property value will lead to the error: "Application session scope is not set". |
|
|
|
Whether to publish the application source code on failure or not |
|
|
|
If the value is set to |
|
hostname |
|
Remote grid host to be used to create a new session |
|
username |
|
Remote grid username to be used to create a new session |
|
password |
|
Password to be used to create a new session |
|
ISO-8601 Durations format |
|
Total duration to wait for UI condition |
|
ISO-8601 Durations format |
|
Used together with |
|
The value between 0 and 1 e.g. 0.75 |
|
Enables compressions of the images published to the report using the specified compression quality. If 1 is set then no compression will be performed. It may help to decrease total report size. |
|
|
|
Enable proxy for the whole test run |
|
|
|
Enable proxy recording |
|
any host name resolving on the machine |
|
Overrides the host which will be used by proxy |
|
ports range (e.g., |
|
Ports range which could be occupied for proxy |
|
|
|
Overrides the proxy host which will be passed to browser |
|
|
|
Enables publishing of attachments with HAR to each failed step. |
|
|
|
Whether to disable verification of upstream servers SSL certificates |
|
HAR capture types: |
|
List of HAR capture types |
|
|
|
Whether to enable MITM proxy for the whole test run |
|
|
|
The MITM type using the corresponding certificates. |
|
keystore type |
|
The keystore type |
|
path to keystore |
|
The relative to |
|
password for keystore |
|
The password for keystore |
|
keystore alias |
|
The alias for certificate entry in keystore |
|
|
|
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 |
How to configure user preferences for Chrome browser?
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.
Expressions
The expression parameters marked with bold are mandatory. |
decodeDataUrl
Parses Data URL-s and decodes their data if Base64 encoding is set. The result of the expression depends on the MIME type of Data URL. The result will be a binary data in case of the binary MIME type and it will be a string for the text MIME type.
If expression is applied to invalid Data URL the error will be thrown. |
#{decodeDataUrl($dataUrl)}
-
$dataUrl
- The Data URL to decode.
When I save `src` attribute value of element located `By.id(image)` to scenario variable `image`
When I compare against baseline with name `inlined-image` from image `#{decodeDataUrl(${image})}`
Expression | Result |
---|---|
|
|
|
|
|
|
|
|
|
|
|
Image binary data. |
Dynamic variables
Browser window dimension
The set of dynamic variables provides ability to access height and width of the browser window.
Variable name
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`
Context element rectangle
The set of dynamic variables provides ability to access context element coordinates, width and height.
The variables rely on the contextual approach: it is necessary to switch context to the target element. |
In case of missing search context the error will be logged and -1 will be returned as a result
|
Variable name
Variable name | Description |
---|---|
|
the height of the context element |
|
the width of the context element |
|
the absolute |
|
the absolute |
When I change context to element located by `id(userpic)`
Then `${context-height}` is > `0`
Then `${context-width}` is > `0`
Then `${context-x-coordinate}` is > `0`
Then `${context-y-coordinate}` is > `0`
Profiles
Profiles allow to choose or parameterize browser that tests run on. See more details on the profiles and nesting strategy on the configuration page.
Web-application plugin contains significant number of built-in profiles. They can be found after plugin installation by the following path in Eclipse IDE:
Referenced Libraries -> vividus-plugin-web-app-X.Y.Z -> properties -> profile -> web
Let’s go through the structure and review its content.
Desktop
General place for web profiles. Each of the directory contains browser related properties. This is a place for adjustments for your browser. Add there any properties you need: screen resolution, path to driver or to a custom browser.
Configure driver path
While executing tests on the local machine it is allowed to use custom browser driver. This approach first requires manually downloading the driver (See Quick Reference Section for download links). The path to the downloaded binary should be configured using the following property:
web.driver.<browser>.driver-executable-path=/path/to/driver/executable
where <browser>
is one of the following values:
-
chrome
-
firefox
-
safari
-
iexplore
-
edge
-
opera
Configure browser path
While executing tests on the local machine it is allowed to configure path to browser executable file. In general cases it’s not required, installed browsers are found automatically (except Opera browser). Also, for example, if browser is not installed, but only downloaded and unpacked into some folder, the path to the downloaded binary should be configured using the following property:
web.driver.<browser>.binary-path=/path/to/custom/browser/executable
where <browser>
is one of the following values:
-
chrome
-
firefox
-
edge
-
opera
List of desktop profiles
Profile | Example of properties | ||
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Mobile emulation
-
Built-in devices
Chrome allows to emulate view on mobile devices using Device mode. Such feature is reflected in
mobile_emulation
subdirectory in Profiles. Use device-name property to mention target device:web.driver.CHROME.mobile-emulation.device-name=DEVICE_NAME
Available for emulation devices you can find in the Dimensions list in chrome.
-
Custom devices
In case you need to use Responsive Viewport Mode and set up your own device, update the screen resolution in the following properties:
web.driver.CHROME.mobile-emulation.width=1440 web.driver.CHROME.mobile-emulation.height=900
Docker
The profile can be enabled by adding web/docker
to configuration.profiles
property. The profile should be used together with the browser profile.
Default selenium grid URL is set to selenium.grid.url=http://localhost:4444/wd/hub . Don’t forget to modify it if your grid is running in a different location.
|
confgiguraiton.profiles=web/docker,web/desktop/chrome
Headless
Headless mode is a functionality that allows the execution of a full version of the browser while controlling it programmatically. It can be used without dedicated graphics or display, meaning that it runs without its “head”, the Graphical User Interface (GUI). Update properties in this directory to adjust your headless automation.
Phone
Contains phone related properties, for android and iOS devices, including portrait and landscape orientations.
Profile | Example of properties |
---|---|
web/phone |
|
Tablet
Similar to the Phone directory, but is designed for tablets properties.
Profile | Example of properties |
---|---|
web/tablet |
|
Steps
Steps opening pages
Open main application page
Loading the page which was associated with the main application page.
Main page can be set by the property web-application.main-page-url
in the property file.
Given I am on main application page
web-application.main-page-url
variableGiven I am on main application page
Open a page with defined URL
Loading the page with a given absolute URL, e.g. https://example.com/.
Given I am on page with URL `$pageURL`
Given I am on page with URL `https://docs.vividus.dev/`
Open page with relative URL
Navigates the browser to the specific path in the current host defined in the relative URL step parameter.
A relative URL can point to a file within a web site (like about.html
or /products
).
-
If the parameter starts with '/' char, navigation will be performed from the root of the host, see examples below.
-
If the parameter starts without '/' char or with './', navigation will be performed from the current path directory.
Current page | Relative URL parameter | Opened page |
---|---|---|
about.html |
||
/products/new |
||
stats |
||
./docs/info.html |
||
/documents |
When I go to relative URL `$relativeURL`
-
relativeURL
- A string value of the relative URL.-
Open main application page and then navigate to '/products/new' page on the application host
-
Given I am on main application page
When I go to relative URL `/products/new`
Clicking steps
Click on element
Clicks on the element found by the specified locator.
The atomic actions performed are:
-
find the element by the locator;
-
click on the element if it is found, otherwise the whole step is failed and its execution stops;
-
the first two actions are retried once if the field becomes stale during actions execution in other words if StaleElementReferenceException is occurred at any atomic action.
If element by the specified locator is not clickable (overlapped by another element, problems with page/context loading or the element is disabled) the step will fail with corresponding error:
|
When I click on element located by `$locator`
-
$locator
- The locator used to find element.
When I click on element located by `name(Submit)`
Click on element without retry
The step is deprecated and will be removed in VIVIDUS 0.6.0. The replacement is Click on element. The replacement pattern is:
|
Clicks on an element found by the locator.
When I click on element located `$locator`
-
$locator
- The locator used to find element.
When I click on element located `name(Submit)`
Scrolling steps
Scroll context
Scrolls the context to an edge
When I scroll context to $scrollDirection edge
-
$scrollDirection
- the direction of the scroll. One of:-
LEFT
- start of a page/element horizontally -
RIGHT
- end of a page/element horizontally -
TOP
- start of a page/element vertically -
BOTTOM
- end of a page/element vertically
-
If the context is not set, the whole page will be scrolled |
When I change context to element located by `id(login)`
When I scroll context to BOTTOM edge
Scroll element into view
Scrolls an element into the view.
When I scroll element located `$locator` into view
-
$locator
- The locator used to find element.
When I scroll element located `id(way_down_button)` into view
Text validation steps
Validate the text exists
Validates that the text is presented in the current context. Expected text is case sensitive.
The context can be set by the corresponding steps. If no context is set, the text will be searched on the whole page.
Then text `$text` exists
-
$text
- Expected text.
Given I am on page with URL `https://docs.vividus.dev/`
Then text `Contract Us` exists
Validate the text does not exists
Validates that the text is not presented in the current context.
The context can be set by the corresponding steps. If no context is set, the text will be searched on the whole page.
Then text `$text` does not exist
-
$text
- Text that should not exist.
When I change context to element located by `id(code)`
Then text `Deprecated` does not exist
Tab steps
Open a new tab
Opens a new browser tab and switches the focus for future commands to this tab.
When I open new tab
When I open new tab
Given I am on page with URL `https://docs.vividus.dev/`
Open URL in a new tab
Opens a new tab, switches the focus to this tab and loads the given URL.
The key difference of this step from the previous one opening a new tab is that this step inherits the state of the previous page, i.e.:
|
When I open URL `$URL` in new window
-
$URL
- The URL to open.
When I open URL `https://docs.vividus.dev` in new window
Close current tab
Closes the current tab and switches to the previous tab.
When I close the current window
Handling alerts displayed with 'onbeforeunload' events is not implied by the WebDriver specification to close window. For handling alerts use step based on JavaScript 'Close current tab with possibility to handle alert'. |
This step can only be applied to a session with multiple tabs open. |
Given I am on page with URL `https://example.com/`
When I open URL `https://example.com/contact-us` in new window
When I close the current window
Close current tab with possibility to handle alert
Trying to close the current tab with 'onbeforeunload' events handling.
-
If an alert window is opened via 'onbeforeunload' event, it must be checked and handled in the subsequent steps.
-
If an alert window is not opened, the step closes the current window and switches to the previous window.
When I attempt to close current window with possibility to handle alert
This step can only be used if the current tab was opened via the step When I open URL `$pageUrl` in new window .
|
If you confirm window close in alert, the tab will be closed, and you will need to switch to current tab using the following step: When I switch to window with title that $stringComparisonRule `$windowName` .
|
Given I am on page with URL `https://example.com/`
When I open URL `https://example.com/form` in new window
When I click on element located by `xpath(//*[@id='form-edit'])`
When I execute sequence of actions:
|type |argument |
|ENTER_TEXT|changed text|
When I attempt to close current window with possibility to handle alert
Then an alert is present
When I accept alert with message which matches `.*`
Execute sequence of actions
Executes the sequence of web actions
When I execute sequence of actions: $actions
-
$actions
- table of actions to executeTable 3. Possible actions type
argument
Argument example DOUBLE_CLICK
Element locator or empty
By.linkUrl(http://httpbin.org)
CLICK_AND_HOLD
Element locator or empty
By.linkText(Click me)
MOVE_BY_OFFSET
Point
(10, 15) where x is 10 and y is 15
RELEASE
Element locator or empty
By.tagName(div)
ENTER_TEXT
Text to type
Minsk City
CLICK
Element locator or empty
By.caseSensitiveText(Done)
PRESS_KEYS
Press and release any of Keys
BACK_SPACE
KEY_DOWN
Press any of Keys one by one
CONTROL,SHIFT,ALT
KEY_UP
Release any of Keys one by one
CONTROL,SHIFT,ALT
MOVE_TO
Element locator
By.id(username)
When I execute sequence of actions:
|type |argument |
|DOUBLE_CLICK |By.fieldText(Hello World) |
|DOUBLE_CLICK | |
|CLICK_AND_HOLD|By.xpath(//signature-pad-control/canvas)|
|CLICK_AND_HOLD| |
|MOVE_BY_OFFSET|(-300, 0) |
|RELEASE |By.xpath(//signature-pad-control/canvas)|
|RELEASE | |
|ENTER_TEXT |Text |
|CLICK |By.placeholder(Enter your password) |
|CLICK | |
|PRESS_KEYS |BACK_SPACE |
|KEY_DOWN |CONTROL,SHIFT |
|KEY_UP |CONTROL,SHIFT |
|MOVE_TO |By.id(name) |
This step can be used to perform clipboard interactions. Example 25. Select all text in the focused field and copy it to the clipboard on Windows
Example 26. Paste text from the clipboard to the focused field on MacOS
|
Browser logs steps
This set of steps allows to validate the browser console logging messages.
In order to configure availability of the INFO level messages use following properties:
|
Validate log entries absence
Validates the absence of log entries of the desired level in the browser console.
Then there are no browser console $logLevels
-
$logLevels
- List of the comma-separated messages levels. The supported levels are: ERRORS, WARNINGS, INFOS.
Given I am on page with URL `https://vividus-test-site.onrender.com/`
Then there are no browser console ERRORS
Validate specific log entries absence
Validates the absence of specific log entries of the desired level in the browser console.
Then there are no browser console $logLevels by regex '$pattern'
-
$logLevels
- List of the comma-separated messages levels. The supported levels are: ERRORS, WARNINGS, INFOS. -
$pattern
- The regular expression to match log entry messages.
Given I am on page with URL `https://vividus-test-site.onrender.com/`
Then there are no browser console ERRORS by regex '.*user.*'
Validate specific log entries presence
Validates the presence of specific log entries of the desired level in the browser console.
Then there are browser console $logLevels by regex '$pattern'
-
$logLevels
- List of the comma-separated messages levels. The supported levels are: ERRORS, WARNINGS, INFOS. -
$pattern
- The regular expression to match log entry messages.
Given I am on page with URL `https://vividus-test-site.onrender.com/`
Then there are browser console ERRORS by regex '.*user.*'
Wait for console log entries and save them
Waits for the appearance of the console log entries with the expected level and which match regular expression and saves all the entries (including awaited ones) of the expected level gathered during the wait to the scoped variable.
Wait uses generic UI timeouts specified by the properties ui.wait.timeout and ui.wait.polling-period . See Properties section for more details.
|
When I wait until browser console $logEntries by regex `$regex` appear and save all entries into $scopes variable `$variableName`
-
$logLevels
- List of the comma-separated messages levels. The supported levels are: ERRORS, WARNINGS, INFOS. -
$pattern
- The regular expression to match log entry messages. -
$variableName
- The name of the variable to save the value of the barcode.
Given I am on page with URL `https://vividus-test-site.onrender.com/`
When I wait until browser console infos by regex `.*Application ready.*` appear and save all entries into scenario variable `logs`
Then `${logs}` matches `.*Application ready in \d+ seconds.*`
Perform steps for each found element
Executes the steps against all elements found by locator. After a required number of elements is found, search context switches in order for each found element and performs all steps on it.
If comparison rule mismatch steps will not be performed even if elements are found. |
When I find $comparisonRule `$number` elements by `$locator` and for each element do$stepsToExecute
Alias:
When I find $comparisonRule '$number' elements by $locator and for each element do$stepsToExecute
-
$comparisonRule
- The comparison rule. -
$number
- The number of elements to find. -
$locator
- The locator used to find elements. -
$stepsToExecute
- The ExamplesTable with a single column containing the steps to execute.
When I find = `5` elements by `By.xpath(//script):a` and for each element do
|step |
|When I set 'type' attribute value of the context element to the 'scenario' variable 'type'|
|Then `${type}` is equal to `text/javascript` |
Wait for window and switch
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-8601 Durations format. -
$comparisonRule
- The window title comparison rule. -
$windowTitle
- The expected window title.
Given I am on page with 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
Stop page loading
Stops page loading
When I stop page loading
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
Configure page load timeout
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-8601 Durations format.
Given I am on page with 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`
Performance metrics
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 navigation start and the load event end.
-
-
$comparisonRule
- The duration comparison rule. -
$duration
- The duration to compare against in ISO-8601 Durations format.
Given I am on page with URL `https://example.com`
Then metric PAGE_LOAD_TIME is less than `PT5S`
Wait for element appearance
Waits for appearance of the element by the locator.
It’s forbidden to use Visibility types in the locator. |
When I wait until element by located `$locator` appears
Deprecated syntax (will be removed in VIVIDUS 0.6.0):
When I wait until element located `$locator` appears
-
$locator
- Locator.
When I wait until element located by `name(welcome-image)` appears
Wait for element disappearance
Waits for disappearance of the element by the locator.
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). |
It’s forbidden to use Visibility types in the locator. |
When I wait until element located by `$locator` disappears
Deprecated syntax (will be removed in VIVIDUS 0.6.0):
When I wait until element located `$locator` disappears
-
$locator
- Locator.
When I wait until element located by `name(welcome-image)` disappears
Wait for expected elements number
Waits for the expected number of elements located by locator.
In order to wait for invisible elements one rely on Visibility types. |
When I wait until number of elements located by `$locator` is $comparisonRule $number
-
$locator
- Locator. -
$comparisonRule
- The comparison rule. -
$number
- The expected number of the elements.
When I wait until number of elements located by `tagName(img)` is equal to `5`
When I wait until number of elements located by `tagName(img):1` is equal to `5`
Verify elements number
Verifies if the number of elements located by locator matches the desired number.
Then number of elements found by `$locator` is $comparisonRule `$quantity`
-
$locator
- Locator. -
$comparisonRule
- The comparison rule. -
$quantity
- The expected number of the elements.
Then number of elements found by `tagName(img)` is equal to `5`
Verify elements state
Verifies if the number of elements located by locator matches the number condition and all of them are in the desired state.
If you describe number condition as equal to 5 in case if there are 10 elements by this locator and only 5 of them in the desired state. You will get two failed assertions. The first one about number condition violation. The second one about state check failure. |
In case when Visibility types are used and checked state are equal (For an example ':i' and 'NOT_VISIBLE') exception will be thrown. In such cases please use step: Verify elements number. Contradictory visibility parameters (locator - ':i' and checked state - 'VISIBLE') are also not allowed. |
Then number of $state elements found by `$locator` is $comparisonRule `$quantity`
-
$state
- State -
$locator
- Locator. -
$comparisonRule
- The comparison rule. -
$quantity
- The expected number of elements.
Then number of VISIBLE elements found by `tagName(img)` is = `1`
Save the text of the context
Saves the text of the context element into a variable.
Step will throw an error if the context element is not set. |
When I save text of context element to $scopes variable `$variableName`
-
$variableName
- The name of the variable to save the text.
When I change context to element located by `id(username)`
When I save text of context element to SCENARIO variable `username`
Saves the attribute value of the context
Saves the attribute value of the context element into a variable.
Step will throw an error if the context element is not set. |
When I save `$attributeName` attribute value of context element to $scopes variable `$variableName`
-
$attributeName
- The name of an element attribute. -
$variableName
- The name of the variable to save the attribute value.
When I change context to element located by `id(username)`
When I save `innerText` attribute value of context element to SCENARIO variable `username`
Save the attribute value of the element
Saves the attribute value of the element located by locator into a variable.
When I save `$attributeName` attribute value of element located `$locator` to $scopes variable `$variableName`
-
$attributeName
- The name of an element attribute. -
$locator
- Locator. -
$variableName
- The name of the variable to save the attribute value.
Save the attribute value of the element
When I save `innerText` attribute value of element located `By.id(username)` to SCENARIO variable `username`
Save number of elements
Saves number of elements located by locator into a variable.
When I save number of elements located `$locator` to $scopes variable `$variableName`
-
$locator
- Locator. -
$variableName
- The name of the variable to save the number of elements.
When I save number of elements located `tagName(a)` to scenario variable `numberOfLinks`
Then `${numberOfLinks}` is equal to `1`
Change context
Changes the context to an element located by locator for limiting area of subsequent UI interactions.
When I change context to element located by `$locator` in scope of current context
Deprecated syntax (will be removed in VIVIDUS 0.7.0):
When I change context to element located `$locator` in scope of current context
-
$locator
- Locator.
Then number of elements found by `By.xpath(html)` is equal to `1`
When I change context to element located by `xpath(//body)` in scope of current context
Then number of elements found by `By.xpath(html)` is equal to `0`
Reset and change context
Resets current context and changes the context to an element located by locator for limiting area of subsequent UI interactions.
When I change context to element located by `$locator`
Deprecated syntax (will be removed in VIVIDUS 0.7.0):
When I change context to element located `$locator`
-
$locator
- Locator.
Then number of elements found by `By.xpath(html)` is equal to `1`
When I change context to element located by `xpath(//body)`
Then number of elements found by `By.xpath(html)` is equal to `0`
Reset context
Resets the context.
When I reset context
Then number of elements found by `By.xpath(html)` is equal to `1`
When I change context to element located by `xpath(//body)`
Then number of elements found by `By.xpath(html)` is equal to `0`
When I reset context
Then number of elements found by `By.xpath(html)` is equal to `1`
Element existence during the time period
Validates the element located by the locator has existed for the period specified by the duration.
The actions performed by the step:
-
check the search context is set,
-
search for the element to validate existence (this search may include wait for element appearance if it’s configured),
-
validate the element has presented for the period specified by the duration.
Then element located by `$locator` exists for `$duration` duration
Deprecated syntax (will be removed in VIVIDUS 0.6.0):
Then element located `$locator` exists for `$duration` duration
-
$locator
- The Locator to find an element. -
$duration
- The period of time the element should have existed in ISO-8601 Durations format.
Then element located by `id(banner)` exists for `PT5S` duration
Navigate back
Navigates back to the previous view.
When I navigate back
Then number of elements found by `xpath(//*[@*='Welcome'])` is equal to `1`
When I navigate back
Then number of elements found by `xpath(//*[@*='Welcome'])` is equal to `0`
Verify elements order
Gets a collection of elements by locator and checks that they are sorted by their text in the specified order. The collection should have more than 1 element with not empty text, otherwise the step fails.
Then elements located $locator are sorted by text in $sortingOrder order
Then elements located by $locator are sorted by text in $sortingOrder order
-
$locator
- Locator. -
$sortingOrder
Plain | Readable | Description |
---|---|---|
ASCENDING |
ascending |
Verify that elements are sorted in ascending order |
DESCENDING |
descending |
Verify that elements are sorted in descending order |
CASE_INSENSITIVE_ASCENDING |
case-insensitive ascending |
Verify that elements are sorted in case-insensitive ascending order |
CASE_INSENSITIVE_DESCENDING |
case-insensitive descending |
Verify that elements are sorted in case-insensitive descending order |
Given I am on page with URL `https://grocery.by`
When I click on element located by `id(a-z)`
Then elements located by `xpath(//span[@id='item-to-purchase'])` are sorted by text in ascending order
Take a screenshot and save it to the folder
Takes a screenshot and saves it to the default folder defined by user.
The full path to a screenshot will be posted to logs and allure |
When I take screenshot and save it to folder `$path`
-
$path
- The absolute or relative path to the folder to save taken screenshot.
When I take screenshot and save it to folder `${screenshot-directory}/#{generate(Ancient.god)}.png`
Scan barcode
Scan a barcode and save its value to the variable with the specified name. Only the first founded barcode will be scanned.
Supported Code Formats
1D product | 1D industrial | 2D |
---|---|---|
|
|
|
Actions performed at this step:
-
Takes a viewport screenshot
-
Scans a barcode from the screenshot and save its value to the variable
When I scan barcode from screen and save result to $scopes variable `$variableName`
-
$variableName
- The name of the variable to save the value of the barcode.
When I scan barcode from screen and save result to scenario variable `qrCodeLink`
Then `${qrCodeLink}` is equal to `https://www.example.com`
Perform steps while elements exist
Executes the steps while the found elements exist.
To avoid infinite loops the iterationLimit parameter is used. If iteration’s limit reached the step will fail. |
When I find $comparisonRule `$number` elements `$locator` and while they exist do up to $iterationLimit iteration of$stepsToExecute
Alias:
When I find $comparisonRule '$number' elements $locator and while they exist do up to $iterationLimit iteration of$stepsToExecute
-
$comparisonRule
- The comparison rule. -
$number
- The number of elements to find. -
$locator
- Locator. -
$iterationLimit
- The maximum number of iterations to perform. -
$stepsToExecute
- The ExamplesTable with a single column containing the steps to execute.
When I find >= `0` elements `xpath(//*[@class='menu enabled'])` and while they exist do up to 10 iteration of
|step |
|When I click on element located by `id(disable)`|
Execute JavaScript with arguments
Executes JavaScript via JavascriptExecutor. Step executes the script either without any arguments or with String
or Object
argument types.
When I execute javascript `$script` with arguments:$arguments
-
$script
- The JavaScript code to execute. -
$arguments
- The examples table with set of arguments and their type:-
value
- The value of the argument. -
type
- The type of the argument. Eitherstring
orobject
.
-
When I execute javascript `document.querySelector('#assistant').remove()` with arguments:
When I execute javascript `sauce:inject-image` with arguments:
|value |type |
|iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=|string|
When I execute javascript `sauce:throttleCPU` with arguments:
|value |type |
|{"rate" : 4}|object|
Execute JavaScript and save result.
Executes JavaScript code and saves result into variable.
When I execute javascript `$jsCode` and save result to $scopes variable `$variableName`
-
$jsCode
- Any JavaScript code. In order to save a result return statement should be used. -
$variableName
- The variable name to script execution result.
Given I am on page with URL `https://vividus-test-site.onrender.com/`
When I execute javascript `return JSON.stringify(window.performance.timing)` and save result to scenario variable `timings`
Then number of JSON elements from `${timings}` by JSON path `$.connectStart` is = 1
Scan barcode from context
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
1D product | 1D industrial | 2D |
---|---|---|
|
|
|
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`
-
$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`
Field Steps
Fields are elements where users can enter data. The most typical fields are:
Enter text in field
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)`
Add text to field
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)`
Clear field
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)`
Clear field using keyboard
Clears the field found by the specified locator using keyboard. The step simulates user action by pressing buttons Ctrl+A and then 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
Dropdown Steps
Validate available options
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 |
The item is an option. The state (true or false ) specifies whether the item is selected.
|
Validate the first selected option
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`
Add an option to the mutli-select dropdown
Selects option in multi-select dropdown
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)`
Select the option
Selects option in dropdown
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)`
Cookie Steps
Validate cookie presence
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
Validate cookie absence
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
Set cookies
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 |/ |
Get cookie value
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. -
$variableName
- The variable name to save the cookie value.
When I save value of cookie with name `JSESSIONID` to scenario variable `session-id`
Get cookie
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. -
$variableName
- The variable name to save the cookie.
When I save cookie with name `JSESSIONID` as JSON to scenario variable `session-id`
Remove cookie
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
Remove cookie without apply
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
Web Storage steps
Get web storage item
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. -
$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`
Set web storage item
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`
Validate web storage item presence
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
Validate web storage item absence
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
Proxy Steps
Check the number of HTTP requests
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level.
The actions preformed by the step:
-
extract HTTP messages from the recorded proxy archive
-
filter out the HTTP messages with the response status code
302 Moved Temporarily
-
find HTTP requests matching the provided HTTP methods and the URL regular expression
-
check that the total number of the found HTTP messages satisfies the desired condition
In case of failure the full HTTP archive (HAR) is attached to the report.
Then number of HTTP $httpMethods requests with URL pattern `$urlPattern` is $comparisonRule `$number`
-
$httpMethods
- The comma-separated HTTP methods to filter by -
$urlPattern
- The regular expression to match HTTP request URL -
$comparisonRule
- Comparison Rule -
$number
- The number to compare with
Then number of HTTP GET, POST requests with URL pattern `http://httpbin\.org/get` is equal to `1`
Capture HTTP message
Save the HTTP message part from the HTTP request with given URL-pattern into the variable with specified name and the scopes.
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level.
The actions preformed by the step:
-
extract HTTP messages from the recorded proxy archive
-
filter out the HTTP messages with the response status code
302 Moved Temporarily
-
find HTTP requests matching the provided HTTP methods and the URL regular expression
-
check that total number of the found HTTP messages is equal to
1
-
save the HTTP message part to the specified variable
In case of failure the full HTTP archive (HAR) is attached to the report.
When I capture HTTP $httpMethods request with URL pattern `$urlPattern` and save $httpMessagePart to $scopes variable `$variableName`
-
$httpMethods
- The "or"-separated set of HTTP methods to filter by, e.g.GET or POST or PUT
. -
$urlPattern
- The regular expression to match HTTP request URL. -
$httpMessagePart
- The HTTP message part to save. One of:-
URL
- The request URL. -
URL query
- The request URL query parameters. -
request data
- The request data includes the following keys:-
query
- The URL query is stored as a collection of key and value pairs, where key is the name of the query parameter and value is the list of query parameter values. The query parameter values are accessible via zero-based index. -
requestBody.mimeType
- The MIME type of posted data, the variable will not be saved if MIME type is not present. -
requestBody.text
- The posted data as plain text, the variable will not be saved if the request body is not present. -
requestBodyParameters
- The form data parameters are stored as a collection of key and value pairs, where key is the name of the form parameter and value is the list of form parameter values. The form parameter values are accessible via zero-based index. -
responseStatus
- The response status, the variable will not be saved if the response is not present.
-
-
response data
- The response data includes the following keys:-
responseBody.mimeType
- The MIME type of response data, the variable will not be saved if MIME type is not present. -
responseBody.text
- The response data as plain text, the variable will not be saved if the response body is not present.
-
-
-
$variableName
- The variable name to save the HTTP message part.
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I capture HTTP GET or POST request with URL pattern `.*/search.*=vividus` and save URL to scenario variable `URL`
Then `${URL}` is equal to `https://www.google.com/search?q=vividus`
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I capture HTTP GET request with URL pattern `.*/search.*=vividus` and save URL query to scenario variable `query`
Then `${query.q[0]}` is equal to `vividus`
Then `${query.q}` is equal to `[vividus]`
Then `${query}` is equal to `{q=[vividus]}`
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I capture HTTP GET request with URL pattern `https://www.google.com/search?q=vividus` and save request data to scenario variable `data`
Then `${data.query}` is equal to `{}`
Then `${data.requestBodyParameters}` is equal to `{delivery=, custtel=, comments=, custemail=, custname=}`
Then `${data.requestBody}` is not equal to `null`
Then `${data.responseStatus}` is equal to `200`
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I capture HTTP GET request with URL pattern `https://www.google.com/search?q=vividus` and save request data to scenario variable `data`
Then `${data.responseBody.text}` is equal to `{"status": "ok"}`
Then `${data.responseBody.mimeType}` is equal to `application/json`
Wait for the HTTP request
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. Waits for the HTTP requests matching the provided HTTP methods and URL regular expression. If no HTTP request is sent and wait timeout is reached, then the step will fail.
When I wait until HTTP $httpMethods request with URL pattern `$urlPattern` exists in proxy log
-
$httpMethods
- the "or"-separated HTTP methods to filter by, e.g. 'GET or POST or PUT' -
$urlPattern
- the regular expression to match HTTP request URL
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I wait until HTTP GET or POST request with URL pattern `https://www.google.com/search?q=vividus` exists in proxy log
Then number of HTTP GET or POST requests with URL pattern `https://www.google.com/search?q=vividus` is equal to `1`
Add headers to the HTTP request
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. Add headers to the proxied HTTP request satisfying the desired condition
When I add headers to proxied requests with URL pattern which $comparisonRule `$url`:$headers
-
$comparisonRule
- String comparison rule -
$url
- The input value of URL to filter by -
$headers
- The ExamplesTable representing the list of the headers with columns "name" and "value" specifying HTTP header names and values respectively
When I add headers to proxied requests with URL pattern which is equal to `https://www.google.com/search?q=vividus`:
|name |value |
|testName1|testValue1|
|testName2|testValue2|
Given I am on page with URL `https://www.google.com/search?q=vividus`
Then a JSON element from '${response}' by the JSON path '$.headers' is equal to '
{
"Testname1": "testValue1",
"Testname2": "testValue2"
}
'ignoring extra fields
Clear the recordings
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. The step clears the HTTP requests and responses recorded by the proxy
When I clear proxy log
Given I am on page with URL `https://www.google.com/search?q=vividus`
When I clear proxy log
Then number of HTTP GET requests with URL pattern 'https://www.google.com/search?q=vividus' is equal to `0`
Clear the mocks
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. The step clears previously created mocks
When I clear proxy mocks
When I mock HTTP responses with request URL which CONTAINS `vividus` using response code `200`, content `#{loadResource(page.html)}` and headers:
|name |value |
|Content-Type|text/html|
When I clear proxy mocks
Given I am on page with URL `https://www.google.com/search?q=vividus`
Then number of elements found by `id(sw)` is = `0`
Mock the HTTP response by methods with content
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. Mocks HTTP response by methods with a provided content
No actual request will be executed. Short-circuited response will be returned. |
When I mock HTTP $httpMethods responses with request URL which $comparisonRule `$url` using response code `$responseCode`, content `$payload` and headers:$headers
-
$httpMethods
- The "or"-separated set of HTTP methods to filter by, e.g.GET or POST or PUT
. -
$rule
- String comparison rule -
$url
- The input value of URL to filter by -
$code
- The response status code -
$content
- The content to send within a response -
$headers
- The ExamplesTable representing the list of the headers with columns "name" and "value" specifying HTTP header names and values respectively
When I mock HTTP POST responses with request URL which CONTAINS `example` using response code `202`, content `#{loadResource(mocked-example.json)}` and headers:
|name |value |
|Content-Type|application/json|
Mock the HTTP response with content
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. Mocks HTTP response with a provided content
No actual request will be executed. Short-circuited response will be returned. |
When I mock HTTP responses with request URL which $comparisonRule `$url` using response code `$responseCode`, content `$payload` and headers:$headers
-
$rule
- String comparison rule -
$url
- The input value of URL to filter by -
$code
- The response status code -
$content
- The content to send within a response -
$headers
- The ExamplesTable representing the list of the headers with columns "name" and "value" specifying HTTP header names and values respectively
When I mock HTTP responses with request URL which CONTAINS `example.com` using response code `200`, content `#{loadResourceAsByteArray(page.html)}` and headers:
|name |value |
|Content-Type|text/html|
Mock the HTTP response without content
This step requires proxy to be turned on. It can be done in properties or by switching on @proxy meta tag at the story level. Mocks HTTP response
No actual request will be executed. Short-circuited response will be returned. |
When I mock HTTP responses with request URL which $comparisonRule `$url` using response code `$responseCode` and headers:$headers
-
$rule
- String comparison rule -
$url
- The input value of URL to filter by -
$code
- The response status code -
$headers
- The ExamplesTable representing the list of the headers with columns "name" and "value" specifying HTTP header names and values respectively
When I mock HTTP responses with request URL which CONTAINS `example.com` using response code `404` and headers:
|name |value|
|Content-Length|0 |
Window Steps
Resize the current browser window
Changes the current browser window size to the specified one.
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 page with URL `https://example.com/`
When I change window size to `640x320`
Video steps
Steps allow to interact with video elements.
Play Video
Starts video playback.
When I play video in video player located `$locator`
-
$locator
- The locator used to find video player.
Pause Video
Pauses video playback.
When I pause video in video player located `$locator`
-
$locator
- The locator used to find video player.
Rewind Video
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.
Get info
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. -
$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 page with 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.+`
Browser Configuration Steps
Set the browser command line arguments
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 main application page
Code steps
Execute async JavaScript and save result.
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. -
$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 `.+`
Element wait steps
Wait for disappearance of an element with a tag
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
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
Wait for element disappearance with timeout
Waits for element disappearance with desired timeout.
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-8601 Durations 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'