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.
To define a variable, create a recording or view an existing recording and select the Input step that you’d like to associate with a variable. After selecting the Input step, you’ll see a Use Variable button in the Detail view:
Clicking on this button will open a modal which lists all of the variables you’ve previously created, along with a form that lets you add a new variable:
Either select an existing variable or add a new variable and then select it, then click the Select Variable button to associate it with your Input step.
To generate a dynamic value for a given variable,
you can use one of several supported functions in your variable definition.
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|