Global variables
Global variables are variables defined in the execution profile and can be used in a test case, test object, web service object, and email configuration in a project.
For example, in a test case, you can use global variables to input data for keywords in Manual view (see highlighted in blue), or to input parameters when binding data for test execution (see highlighted in red).
Add a global variable
Use global variable in test object
To use a global variable in a test object, enter the syntax ${GlobalVariable.name}
in the supported selection methods.
For example:
- In the HTTP Body of an API test object:
- In the Selected Locator of a WebUI test object:
- In a Web service request path:
Use escaping and special characters
To use a special character like $
or \
as a regular one in any place that calls global variables, prepend it with a backslash: \
(the so-called escape character).
{
"productName": ${GlobalVariable.productName},
"unit": "\\bottle\",
"quantity": 50,
"discount": ${ if (productName == "wine") { return 30 } else { return 0}}
"note": "Currency unit of ${GlobalVariable.productName} is \$."
}
- Without
\
: note: Currency unit of ${GlobalVariable.productName} is $. - With
\
: note: Currency unit of wine is $.
See also
For more detailed instructions on parameterizing test objects in Katalon Studio, refer to: