Skip to content

Latest commit

 

History

History
1394 lines (1033 loc) · 40.5 KB

plugin-web-app.adoc

File metadata and controls

1394 lines (1033 loc) · 40.5 KB

Web Application Plugin

The plugin provides functionality to interact with Web applications.

plugins:partial$plugin-web-app-locators.adoc

Properties

Note
The properties marked with bold are mandatory.
Property Name Acceptable values Default Description

selenium.grid.platform-name

Valid target platform name

empty

Identifies the operating system for the testing. e.g. Windows

selenium.grid.platform-version

Valid target platform version

empty

Identifies the operating system version for the testing. e.g. 10

partial$selenium-properties.adoc partial$proxy-properties.adoc

screenshot.on-failure.debug-modes

proxy

<empty>

Provides possibility to attach screenshot for failed proxy steps

web.timeouts.page-load

{durations-format-link}

PT1M

Sets the amount of time to wait for a page load to complete before throwing an error.

web.timeouts.async-script

{durations-format-link}

PT1M

Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.

web.driver.<browser-name>.command-line-arguments

string with arguments

<empty>

The command line (CLI) arguments to use when starting browser.

<browser-name> is one of the browsers supporting CLI arguments:

web-application.sticky-header-size-percentage

header size as a viewport size percent

25

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.

Add the following property to allow all cookies
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

Note
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.

Warning
If expression is applied to invalid Data URL the error will be thrown.
#{decodeDataUrl($dataUrl)}
  • $dataUrl - The Data URL to decode.

Decoding inlined image
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})}`
Table 1. Examples of the expressions decoding Data URL
Expression Result

#{decodeDataUrl(data:,value)}

value

#{decodeDataUrl(data:text/plain,value)}

value

#{decodeDataUrl(data:;base64,SGVsbG8sIFdvcmxkIQ==)}

Hello, World!

#{decodeDataUrl(data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==)}

Hello, World!

#{decodeDataUrl(data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==)}

Hello, World!

#{decodeDataUrl(data:image/png;base64,iVBORw…​.)}

Image binary data.

Dynamic variables

Current page URL

The variable provides the URL of the page currently loaded in the browser.

${current-page-url}
Validate redirect in the browser
Given I am on page with URL `https://docs.vividus.dev/`
Then `${current-page-url}` is equal to `https://docs.vividus.dev/vividus/latest/index.html`

Browser window dimension

The set of dynamic variables provides ability to access height and width of the browser window.

Variable name Description

browser-window-height

the height of the browser window

browser-window-width

the width of the browser window

Check the dimension 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

Steps

plugins:partial$plugin-web-app-steps.adoc

Close browser

Closes the browser.

When I close browser

Wait for tab and switch

Waits for the tab with desired title and switches to it.

When I wait `$duration` until tab with title that $comparisonRule `$title` appears and switch to it

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I wait `$duration` until window with title that $comparisonRule `$windowTitile` appears and switch to it
  • $duration - The timeout duration to wait for a tab in {durations-format-link} format.

  • $comparisonRule - The tab title comparison rule.

  • $title - The expected tab title.

Wait for tab and switch to it
Given I am on page with URL `https://vividus-test-site-a92k.onrender.com/windows.html`
When I click on element located by `id(timeout)`
When I wait `PT3S` until tab 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
Tip
Could be useful in combination with Selenium’s page load strategy
Stop page loading.story
When I open URL `https://delayed.vividus.dev` in new tab
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 {durations-format-link} format.

Before loading a heavy page set an increased timeout
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 tab
When I set page load timeout to `PT10S`

Performance metrics

Checks web performance metrics.

Then metric $webPerformanceMetric is $comparisonRule `$duration`
Check page load
Given I am on page with URL `https://example.com`
Then metric PAGE_LOAD_TIME is less than `PT5S`

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

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.

Scan 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`

Upload file

Uploads the {resource or file via web interface.

When I select element located by `$locator` and upload `$resourceNameOrFilePath`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I select element located `$locator` and upload file `$filePath`
  • $locator - the locator of the web element with input tag and attribute type=file

  • $resourceNameOrFilePath - relative path to the file to be uploaded

Upload file_for_upload.png file
When I select element located by `id(uploadfile)` and upload file `/folder/file_for_upload.png`

Verify page is not refreshed after click on element

Clicks on the element and checks that the page has not been refreshed after the click.

When I click on element located by `$locator` then page does not refresh

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I click on an element '$locator' then the page does not refresh
  • $locator - The locator to find an element to click.

Step example
When I click on element located by `id(send)` then page does not refresh

Right-click on the element

Performs right-click on the element.

When I perform right-click on element located by `$locator`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I perform right click on element located `$locator`
  • $locator - The locator to find an element to click.

Step example
When I perform right-click on element located by `id(clickme)`

Hover mouse over the element

Moves a mouse cursor on the element.

When I hover mouse over element located by `$locator`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I hover mouse over element located `$locator`
  • $locator - The locator to an element to hover.

Step example
When I hover mouse over element located by `id(hoverme)`

Check each element has a specific number of children elements

Checks that each element specified by the locator contains an exact number of visible child elements specified by another locator

Then each element with locator `$elementLocator` has `$number` child elements with locator `$childLocator`
  • $elementLocator - The locator to the parent element.

  • $number - The expected number of children elements

  • $childLocator - The locator to the child elements.

Step example
Then each element with locator `id(menu)` has `5` child elements with locator `id(menu-item)`

Check an element CSS property

Checks the context element has the expected CSS property.

The context can be set by the corresponding steps.

Then context element has CSS property `$cssName` with value that $comparisonRule `$cssValue`
  • $cssName - A name of the CSS property.

  • $comparisonRule - CSS property comparison rule.

  • $cssValue - The expected value of the CSS property.

Change context to element and verify it color CSS property value
When I change context to element located by `id(rainbow)`
Then context element has CSS property `color` with value that is equal to `rgba(0, 0, 0, 1)`

Compare sizes of the elements

Check that all elements found on the page by the given locator have the same dimension: width / height.

Note
Element’s dimension is measured in pixels and means the size that given element occupies on the web-page in a browser. Element size may vary in different browsers, it also depends on screen resolution, page scaling, scripts running on the page.
Then each element located by `$locator` has same `$dimension`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

Then each element located `$locator` has same `$dimension`
  • $locator - The locator to find an elements to compare.

  • $dimension - The elements dimension to compare. Possible values: width, height

Check that all menu items have the same size (width and height)
Then each element located `id(context-menu-item)` has same `width`
Then each element located `id(context-menu-item)` has same `height`

Check element width in a percentage

Checks that the context element has an expected width in a percentage (from the style attribute) relative to the page body.

The context can be set by the corresponding steps.

Then context element has width of $widthPercentage%

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

Then the context has a width of '$widthPercentage'%
  • widthPercentage - An expected element width in a percentage relative to the page body.

Check element width
When I change context to element located by `id(menu)`
Then context element has width of 30%

Check element width in a percentage relative to the parent element

Checks that the context element has an expected width in a percentage (from the style attribute) relative to the parent element

The context can be set by the corresponding steps.

Then context element has width of $widthPercentage% relative to parent element

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

Then the context element has a width of 'widthPercentage'% relative to the parent element
  • widthPercentage - An expected element width in a percentage.

Check element width
When I change context to element located by `id(menu)`
Then context element has width of 13% relative to parent element

Focus Steps

Focus indicates the act of selecting an element of a graphical user interface. Text entered at the keyboard or pasted from a clipboard is sent to the component which has the focus.

Set focus on the context element

Sets the focus on the context element, if it can be focused. The focused element is the element that will receive keyboard and similar events by default.

When I set focus on context element
Set focus on the element with ID "input-username"
When I change context to element located by `id(input-username)`
When I set focus on context element

Set focus on the element

Sets the focus on the element found by the specified locator, if it can be focused. The focused element is the element that will receive keyboard and similar events by default.

When I set focus on element located by `$locator`
  • $locator - The locator to find an element.

Set focus on the element with ID "input-username"
When I set focus on element located by `id(input-username)`

Check the context element focus state

Checks if the context element is in the provided focus state by comparing the context element and the active element.

Then context element is $focusState
  • $focusState - The state to verify: in focus or not in focus.

Check the context element is in focus and do keyboard input
Then context element is in focus
When I press ENTER on keyboard

Check the element focus state

Checks if the element found by the specified locator is in the provided focus state by comparing the found element and the active element

Then element located by `$locator` is $focusState
  • $locator - The locator to find an element.

  • $focusState - The state to verify: in focus or not in focus.

Check the element with ID "input-username" is in focus and do keyboard input
Then element located by `id(input-username)` is in focus
When I change context to element located by `id(input-username)`
When I press ENTER on keyboard

Field Steps

Fields are elements where users can enter data. The most typical fields are:

  • input,

  • textarea,

  • CKE editor (it usually should be located via body tag, that is contained in a frame as a separate HTML document).

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 to find a field.

Add text 'pa$$w0rd' in password 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.

Add text 'name' to username 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 a field.

Clear username 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 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 a field.

Clear password field using keyboard
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 by `$locator` contains options:$options

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

Then dropdown located `$locator` contains options:$options
  • $locator - The locator used to find a dropdown.

  • $options - examples table describing expected options

Validate dropdown contains a set of colors
Then dropdown located by `id(colors)` contains options:
|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.

Validate the first selected option

Verifies if dropdown located by locator exists and first selected option.

Then dropdown located by `$locator` exists and selected option is `$option`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

Then dropdown located `$locator` exists and selected option is `$option`
  • $locator - The locator used to find a dropdown.

  • $option - first selected option

Dropdown.story
Then dropdown located by `id(colors)` exists and selected option is `Blue`

Add an option to the mutli-select dropdown

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 by `$locator`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I add `$option` to selection in dropdown located `$locator`
  • $option - option to select

  • $locator - The locator used to find a dropdown.

Dropdown.story
When I add `Two` to selection in dropdown located by `id(numbers)`

Select the option

Selects option in dropdown

Important
Does not support multi-selection
When I select `$option` in dropdown located by `$locator`

Deprecated syntax (will be removed in VIVIDUS 0.7.0):

When I select `$option` in dropdown located `$locator`
  • $option - option to select

  • $locator - The locator used to find a dropdown.

Dropdown.story
When I select `Red` in dropdown located by `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.

Check the session cookie is present
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.

Check the session cookie is not present
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

Set the cookie for the current domain
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.

Get the value of the session cookie
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.

Get the session 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.

Remove the session cookie
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.

Remove the session cookie
When I remove cookie with name `JSESSIONID` from current domain without applying changes
When I refresh page

Remove all cookies

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

Remove all cookies without apply

Removes all cookies 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 all cookies from current domain without applying changes

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: either local or session.

  • $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.

Get the value of the local 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: either local or session.

  • $key - The name of the key to create/update.

  • $value - The value to give the key that is creating/updating.

Set the session storage item
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: either local or session.

  • $key - The name of the key to check presence.

Check the session storage item is present
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: either local or session.

  • $key - The key of the local storage item to check absence.

Check the local storage item is not present
Then local storage item with key `token` does not exist

Window Steps

Resize the current browser window

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.

Resize the browser window
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 a video player.

Pause Video

Pauses video playback.

When I pause video in video player located `$locator`
  • $locator - The locator used to find a 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 a 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.

  • $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

Video player verifications
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 the property and the step are used - arguments from the property will be ignored. The step will take effect for all new browser sessions created in the current story. It will not affect the current sessions.

Popular browsers supporting command line arguments configuration:

Not supported browsers:

  • Safari

When I set browser command line arguments to `$argsString`
  • $argsString - Sequence of command line arguments, separated by space.

Set the browser to use the mocked camera stream
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.

  • $scopes - The comma-separated set of the variables scopes.

  • $variableName - The variable name to save the cookie value.

Validate response
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 element disappearance with timeout

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`
  • $locator - The locator used to element.

  • $timeout - The maximum time to wait for the element disappearance in {durations-format-link} format.

Click on the button and waiting for disappearance of the element for 3 seconds
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'

Set Variable Steps

Save HTML table to the variable

This step allows you to save an HTML table from a specified context into a variable.

For more information, see how to work with table variables

Important
The HTML table must have a header row with <th> tags.
When I save table to $scopes variable `$variableName`
  • $scopes - The comma-separated set of the variables scopes.

  • $variableName - The variable name to refer to the variable value.

Note
Before using this step, ensure the context is set to the required table. See the example below.
Save the first table on the page into a variable named 'table'
When I change context to element located `xpath(//table[1])`
When I save table to SCENARIO variable `table`

Save the number of opened tabs

Saves the number of currently opened tabs in the browser to the variable.

When I save number of open tabs to $scopes variable `$variableName`
  • $scopes - The comma-separated set of the variables scopes.

  • $variableName - The variable name to refer to the variable value.

Save the number of currently opened browser tabs into a variable named 'count'
When I save number of open tabs to SCENARIO variable `count`

Alert Steps

Perform action in the alert box

Accepts the action in popup alert with matching text by clicking on the "OK" button or dismiss it by clicking "Cancel" button.

Actions performed at this step:

  • Finds the appropriate alert with matching message

  • Performs the corresponding action

When I $alertAction alert with message which $comparisonRule `$message`
  • $alertAction - Action to perform. Possible values: ACCEPT, DISMISS.

  • $comparisonRule - String comparison rule.

  • $message - The text message of the alert.

Accept popup alert with any text message
When I accept alert with message which matches `.*`

Type text in the alert input field

This step allows you to type text into popup alert input field and then accept the alert.

Note
This step is applicable only for alerts with a single input field. For authorization alerts, basic URL authorization should be used. For example, https://user:pass@domain.com
When I type text `$text` in alert and accept it
  • $text - The text to be typed into the alert input field.

Type text 'VIVIDUS' into alert and close it by clicking OK button
When I type text `VIVIDUS` in alert and accept it

Verify that an alert is present

Checks that there is popup alert on the page.

Then an alert is present
Check that an alert appears after clicking on the button
When I click on element located by `buttonName(Survey)`
Then an alert is present

Verify that an alert isn’t present

Checks that there is no any {popup-alert}[popup alerts] on the page.

Then an alert is not present
Check that an alert doesn’t appear on the page
Given I am on page with URL `http://example.com`
Then an alert is not present

Tips & Tricks

Validate URL host of the opened page

To validate host component of the current page URL the following statement can be used:

Given I am on page with URL `https://example.com/relative/url/example.html`
Then `#{extractHostFromUrl(${current-page-url})}` is equal to `example.com`

Validate URL path of the opened page

To validate path component of the current page URL the following statement can be used:

Given I am on page with URL `https://example.com/relative/url/example.html`
Then `#{extractPathFromUrl(${current-page-url})}` is equal to `/relative/url/example.html`

Validate URL of the opened page partially

To validate whether current page URL contains some part the following statement can be used:

Given I am on page with URL `https://example.com/relative/url/example.html`
Then `${current-page-url}` matches `.+\/relative\/url.+`
  • ${current-page-url} is the current page URL dynamic variable.

  • .\/relative\/url. is a regular expression to match the expected part of the page URL.