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

User-Defined Variables

PreviousScriptNextStatic Variables

Last updated 5 years ago

Was this helpful?

The Variables section is a key-value storage for storing and reusing some data. It is often used for removing code duplicates and improving readability: the greetingUrl variable says more than just the line for sure.

The variables mechanism is very well integrated to all application parts and has several features:

  • You can use strings, objects, arrays, and links to other variables as values.

  • Variables are defined for each node and are inherited from parent nodes.

  • Variables values can refer to other variables.

  • names start with $.

Using Variables

You can use variables in any string parameters of the node - URLs, headers names, authorization tokens, etc. To do that, use the ${variableName} syntax, where variableName is a link to the variable. Here are some examples:

  • ${id}

  • ${$dynamicVar.id}

  • ${$response.body.name}

It's possible to combine strings and links to other variables in the node parameters fields. For instance, you can use http://${host}/posts/${$dynamicVar.id} as an URL.

To access an array element, that is stored in a variable, you can use the ${variableName[index]} syntax. For example, to access the third response entity id, you'll write ${$response.body[2].id}. Note that it the index is zero-based.

Autocompletion works for variables:

Variable value highlighting works as well:

There is the Variables button in every node interface, that opens the variables dialog. This is how the button looks like:

The button looks the same for all node types. You'll learn more about how to work with variables in the next sections.

https://next.json-generator.com/api/json/get/EJvQVEVGL
Default variables
Variables autocompletion
Variable value highlighting
The button to open the variables dialog