Dynamic Variables
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.
Variable assignment
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.
So let's create the request and send it. Send a POST request to https://testmace-stage.herokuapp.com/posts with {"title":"Our cool post!"}
in its body. The RequestStep node will look like this:
Open the parsed response and click on the id parameter to see the dynamic variables assignment dialog:
Choose Assign to variable. You'll see the variable assignment dialog:
You can see the following interface parts.
The path to the
$request
where the value is stored.The drop-down list with parents, that you can assign the dynamic variable to.
The current value at the given path.
The dynamic variable name.
Let's create a variable named id
at this node.
After assignment you can find the dynamic variable in the list of the chosen node (RequestStep) dynamic variables. See the list in the variables dialog on the Dynamic variables tab:
Using Dynamic Variables
All dynamic variables available for the chosen node are stored in the $dynamicVar
variable. For example, to access the id
variable you should write $dynamicVar.id
. Just like with other variables, dynamic variables can be inherited from parents or overridden in child elements.
Last updated