Skip to main content

Global variables

A global variable is a variable 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

To add or create a global variable, do as follows:
  1. Go to Tests Explorer > Profiles and open your desired profile.
  2. In the profile manual view, click Add.
  3. Specify details for the variable in the New Variable dialog, then click OK.
  4. The variable is added to the profile accordingly.

Use global variable in test object

To use a global variable in a test object, enter the syntax ${} 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: