Using backtick syntax for JavaScript evaluation

The Recorder enables JavaScript evaluation within any action or locator by using a simple backtick method.

When can you use this scripting method?

This scripting method is helpful when you need to generate a dynamic value or locator for a specific action, or if you need to access global variables declared within the control window.

Some of the more common uses are as follows:

  • Dynamic dates

  • Registration transactions that require a unique email address for each test run

  • Scripts that require randomization (for example, clicking a random search result)

Using this method

The syntax is simple: surround the code to evaluate with backticks ( ` ).


where <jsCode> is any JavaScript code that can be evaluated to generate a string value. For example, to enter in a dynamic email address as a text value for a FormFill action, you can write code as follows:

`'myEmail' + new Date().getTime() + ''`

The backtick method requires that the first and last characters in the field are backticks. The following example is not valid:

myEmail`new Date().getTime()`

Variables defined in the control window can also be used within the backticks. For example, suppose you have the following JavaScript defined within your control window (through a Custom JavaScript function):

var today = new Date();
var later = new Date(today.getTime() + 30*24*60*60*1000);

myDate = (later.getMonth()+1) + '/' + later.getDate() + '/' + later.getFullYear();

To use the value generated for myDate in a FormFill action, enter in the following in the formFill's text value field:


If the variable name is not wrapped in backticks, it is interpreted as a string literal.