Steps available out of the box

Description

Here one could find description of the steps that are delivered with Vividus itself without any plugins required.

Execute while-like loop

Executes the steps while variable matches the comparison rule or until the maximum number of iterations is reached.

If the maximum number of iterations is reached no failure or exception will occur.
When I execute steps at most $max times while variable `$variableName` is $comparisonRule `$expectedValue`:$stepsToExecute

Alias:

When I execute steps at most $max times while variable '$variableName' is $comparisonRule '$expectedValue':$stepsToExecute
  • $max - The maximum number of iterations

  • $variableName - The name of the variable to check

  • $comparisonRule - The comparison rule

  • $expectedValue - The expected value of the variable

  • $stepsToExecute - The ExamplesTable with a single column containing the steps to execute

Example 1. Click button 5 times
When I execute steps at most 5 times while variable `var` is less than `3`:
|step                                                                                                                   |
|When I click on element located `id(counter)`                                                                          |
|When I find <= `1` elements by `xpath(//div[@id='clickResult' and (text()='3' or text()='4')])` and for each element do|
|{headerSeparator=!,valueSeparator=!}                                                                                   |
|!step!                                                                                                                 |
|!When I set the text found in search context to the 'scenario' variable 'var'!                                         |
Then `${var}` is = `3`

Execute while-like loop with delays

Executes the steps while variable matches the comparison rule or until the maximum number of iterations is reached. The delay is used to define the amount of time to wait between iterations.

If the maximum number of iterations is reached no failure or exception will occur.
When I execute steps with delay `$delay` at most $max times while variable variable `$variableName` is $comparisonRule `$expectedValue`:$stepsToExecute

Alias:

When I execute steps with delay '$delay' at most $max times while variable '$variableName' is $comparisonRule '$expectedValue':$stepsToExecute
  • $delay - The delay between iterations

  • $max - The maximum number of iterations

  • $variableName - The name of the variable to check

  • $comparisonRule - The comparison rule

  • $expectedValue - The expected value of the variable

  • $stepsToExecute - The ExamplesTable with a single column containing the steps to execute

Example 2. Click button 5 times with 1 second delay
When I execute steps with delay `PT1S` at most 5 times while variable `var` is less than `3`:
|step                                                                                                                   |
|When I click on element located `id(counter)`                                                                          |
|When I find <= `1` elements by `xpath(//div[@id='clickResult' and (text()='3' or text()='4')])` and for each element do|
|{headerSeparator=!,valueSeparator=!}                                                                                   |
|!step!                                                                                                                 |
|!When I set the text found in search context to the 'scenario' variable 'var'!                                         |
Then `${var}` is = `3`

Wait for period

Waits during specified period for debug purposes

The step is for debugging purpose only
When I wait `$period` for debug
  • $period - total duration to wait in ISO-8601 format

Example 3. Wait 30 seconds for debug
When I wait `PT30S` for debug

Initialize variable using template

Initializes a variable with a result of the processed Freemarker template

Set the template-processor.resolve-bdd-variables property to true value to be able to use global, next batches, scenario and story variables within templates. The variables can be referred using the variable reference notation. Note that the parameters passed to the step take precedence over the variables.

The vividus expressions can be used within templates by using ${execVividusExpression('expression name', args)} syntax. It’s also allowed to use nested expressions by using the following syntax ${execVividusExpression('expression name', arg1, execVividusExpression('expression name', args))}.

Given I initialize the $scopes variable `$variableName` using template `$templatePath` with parameters:$templateParameters
Example 4. Personal info template at templates/person.ftl
{
  "id": ${execVividusExpression('randomInt', 1, 10)},
  "hash": "${execVividusExpression('encodeToBase64', execVividusExpression('randomInt', 100, 1000))}",
  "name": "${name[0]}",
  "race": "${race[0]}",
  "age": ${age}
}
Example 5. Generate JSON from the personal info template
When I initialize the scenario variable `age` with value `4510`
Given I initialize the scenario variable `personalInfo` using template `templates/person.ftl` with parameters:
|name     |race  |
|Dagoth Ur|Dunmer|