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:
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 ( ` ).
`'myEmail' + new Date().getTime() + '@test.com'`
The backtick method requires that the first and last characters in the field are backticks. The following example is not valid:
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.