A dynamic variable is a variable which value is determined when the scenario is run. Apart from other tasks, you can effectively use them for storing authorization tokens or newly created entities. The mechanism consists of two parts - variable assignment and dynamic variables themselves.
You can assign a part of your request to a dynamic variable. For now you can do it in RequestStep nodes only. To illustrate this, let's create a request, that adds a new post and save its id into a dynamic variable.
The RequestStep node after sending a POST request
Open the parsed response and click on the id parameter to see the dynamic variables assignment dialog:
The id parameter context menu
Choose Assign to variable. You'll see the variable assignment dialog:
The dynamic variable assignment dialog
You can see the following interface parts.
- 1.The path to the
$requestwhere the value is stored.
- 2.The drop-down list with parents, that you can assign the dynamic variable to.
- 3.The current value at the given path.
- 4.The dynamic variable name.
Let's create a variable named
idat this node.
The RequestStep node dynamic variables list
To view dynamic variables assigned to a certain node, choose the Values section from the Variables tab. Here’s how this tab looks like for the MyService node from the previous example:
All dynamic variables available for the chosen node are stored in the
$dynamicVarvariable. For example, to access the
idvariable you should write
$dynamicVar.id. Just like with other variables, dynamic variables can be inherited from parents or overridden in child elements.