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

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:

Dynamic Values

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: 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(EEEE M/d/YY)} Meeting: Wednesday 10/7/20
${var(varOne)} and ${var(varTwo)} value1 and value2

In the last example, varOne is defined as value1 and varTwo is defined as value2.

Dynamic Assertions

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:

  • match exactly: Does an exact string match against the specified value, which can reference an existing variable.
  • match using math formula: Asserts that the value is a number matching the formula defined in the Expected Value input. Formula assertions support simple arithmetic, and can utilize both static and dynamic values.
  • match number within range: Asserts that the value is a number within the range of values specified in the From and To fields.
  • match a value in a list: Asserts that the value matches one of the discrete list of items defined in the list.
  • is not empty: Evaluates to true so long as the value is not empty.

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.

Get started with Reflect today

Create your first test in 2 minutes, no installation or setup required. Accelerate your testing efforts with fast and maintainable test suites without writing a line of code.

Copyright © Reflect Software Inc. All Rights Reserved.