Variables
A variable is named value which can be reused. There are 2 ways to define a variable, explicitly define a variable with value or capture a value from response into a variable.
The variables which defined in earlier step, no matter in setup or testcase or teardown, it will be reusable in later steps.
Defining a variable
A variable definition is written in a list item (ordered or unordered list) in the following syntax:
If the value is string, enclose it with double quote. Otherwise, it will be treated as a number. Anyway, if the value cannot be parsed into a number, it will be assumed to be a string.
Example
Defining a variable which has a duplicate name will replace the previous definition. The keyword
in the following example yield the value of "another value"
.
Example
Capturing a value into a variable
See Captures.
Using a variable
The variable can be used within the request code block by putting variable name enclosed with {{
and }}
.
Example
The actual request which sent to server will look like this: