Variables
It's possible to assign values to variables which are then stored in the test context and available to other tests. There are 3 ways to specifiy a variable value.
- As a literal e.g.
store "test@user.com" in a variable called "username"
- From an environment variable e.g.
Store the environment variable $TEST_USER_PASSWORD in the variable "test_pass"
- From a built in function e.g.
Store {{_random(10nlLs)}} in a variable called “password”
Variables are referenced in other test steps by enclosing the variable name in double curly braces e.g.
Type “{{password}}” in the password field
Built in functions
Built in functions are follow the pattern _function(parameters)
. At present there is only one built in function _random()
.
_random()
This function generates a random string suitable for using in a password field. The parameters indicate the length and composition of the string.
The first part of the parameter string is simply the overall length. This is followed by a number of specifiers.
n - a number
l - a lower case letter
L - an upper case letter
s - a special character
For example 10nlL
requests a 10 character random string consisting of numbers, lower case letters and upper case letters.