Configure input values to be dynamically generated or define static values that can be overridden for use in data-driven testing scenarios.
Variables allow you to define input values which can either change on every test run based on your specifications, or be set to a static value that you can override when you run a test. Here’s a few examples of when a variable comes in handy:
Testing Your Registration Flow: Being able to register a user is often one of the most important end-to-end tests you can create. However there’s one big challenge with creating automated tests for this flow: once you’ve registered an email address/username in your system, you can’t register it again. By associating a variable to the username / email address in your test, and assigning it a dynamically generated value, you can ensure that your test registers a new user every time it runs.
Data-Driven Testing: Setting an input value to a variable with a static value allows you to override that value in future test runs. This enables data-driven testing scenarios where you pass in different input values on every test run.
Variables can be defined on both input text and extracted text. To assign input text to a variable, click on the Input step and locate the Variable Assignment section.
Click the Assign to Variable button and give the variable a unique name:
To assign extracted text to a variable, highlight the portion of the extracted value that you wish to assign to a variable, select the Assign to Variable context menu option, and give the variable a unique name:
To generate a dynamic value for a given variable,
you can use one of several supported Functions.
Support for generating random letters and digits comes from the following functions:
Each of these functions takes a value that specifies how many random characters to generate.
range(min,max) function generates a random number between
Support for generating timestamps and dates comes from the following functions:
time(offsetMs) - returns an epoch timestamp after adding
offsetMs milliseconds to the timestamp,
datetime(offsetMs) - returns a date time string of the form
“Wed Oct 07 11:19:04 EDT 2020” after adding
offsetMs milliseconds to the date,
date(format,offsetDays) - returns a formatted date string
offsetDays days to the date.
The supported formats include only the characters:
dDmMyY /, and are parsed using
||Call me, 0149783430|
||Today: Wed Oct 07 11:19:04 EDT 2020|
||Meeting: Wednesday 10/7/20|
||value1 and value2|
In the last example,
varOne is defined as
varTwo is defined as
Reflect automatically extracts text from the elements you interact with. In some cases this text will be static, such as the text on a Sign In button. But in other cases the text could change over time, or potentially on every test run. To assert against dynamic values, click on the test step containing the text you want to assert, and under Expected Text, highlight the text you wish to assert and choose the Add Assertion context menu item:
The following types of assertions are supported:
To assert that this dynamic portion of text matches an existing variable, choose the Match Existing Variable context menu option and select the variable you wish to match against:
In addition to adding these assertions, you can choose to simply ignore text by selecting the Ignore Selection context menu option.
Thanks! Your message has been submitted successfully.
Sorry! Something Went Wrong.