TestMace
0.0.1-beta.7
0.0.1-beta.7
  • Getting Started
  • Interface
    • The Menu
    • Interface Overview
    • Scratches
    • Node Types
    • Keyboard Shortcuts
  • Node Types
    • Project
    • Folder
    • RequestStep
    • Assertion
      • Compare
      • Contains
      • Script
      • XPath
    • Link
    • API description
      • ApiRootFolder
      • ApiFolder
      • ApiRoute
      • API Description Import
    • Broken
    • Script
  • Variables
    • User-Defined Variables
      • Static Variables
      • Dynamic Variables
    • Default Variables
    • Environment Variables
  • Working with the project
    • Cookie
    • Authorization
  • Settings
    • Proxy
  • Other features
    • Bulk Edit
    • Import & Export
      • Shared
      • cURL
      • Swagger
      • Postman
    • Default HTTP headers
Powered by GitBook
On this page

Was this helpful?

  1. Variables
  2. User-Defined Variables

Dynamic Variables

PreviousStatic VariablesNextDefault Variables

Last updated 5 years ago

Was this helpful?

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 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 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.

  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 id at this node.

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.

After assignment you can find the dynamic variable in the list of the chosen node (RequestStep) dynamic variables. See the list in the on the Dynamic variables tab:

variables dialog
RequestStep
https://testmace-stage.herokuapp.com/posts
The RequestStep node after sending a POST request
The id parameter context menu
The dynamic variable assignment dialog
The RequestStep node dynamic variables list