Overview
When using the same variables in more than one test, Global Variables can be implemented to perform a login step in one test, extract and save an authorization token, and then use it to authenticate a connection in another test.
Note: If a global variable hasn't been updated in a week, it is removed from Catchpoint's storage. Global variable naming has a range of 1-32 characters, and Global variable values have a range of 1-1024 characters.
Implementation
How to store and read global variables within Transaction and API tests
Below is the syntax for storing and reading a global variable. For more information for each command, click on their respective names.
storeGlobalVariable(macros, variableName)
${globalVariable(variableName)}
Example
The example below demonstrates how to store a cookie value from a response header as a global variable named "newCookie". Afterward, the Global Variable is read and set as a new cookie in a different test:
//Set Global Variable
open("http://www.google.com")
storeGlobalVariable("${extract(resp-header, regexp:set-cookie: (.*))}", "newCookie")
//Get Global Variable
open("http://www.google.com")
setHeader("Cookie", "${globalVariable(newCookie)}")