Reflect Docs


Configure input values to be dynamically generated or define static values that can be overridden for use in data-driven testing scenarios.

When to Use a Variable

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:

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

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

Defining A Variable

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.

Dynamic Values

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: alpha(len), num(len), and alphanum(len). Each of these functions takes a value that specifies how many random characters to generate. The range(min,max) function generates a random number between min and max, inclusive. 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 after adding offsetDays days to the date. The supported formats include only the characters: dDmMyY /, and are parsed using Java’s SimpleDateFormat.


Definition Example Value
pass${alpha(5)} passboiqg
${alphanum(8)} oq2ki16n
Call me, ${num(10)} Call me, 0149783430
Day: ${range(1,31)} Day: 23
Today: ${time(540)} Today: 1602084695965
Today: ${datetime()} Today: Wed Oct 07 11:19:04 EDT 2020
Meeting: ${date(M/d/YY)} Meeting: 10/7/20
Copyright © 2020 Reflect Software Inc. All Rights Reserved.