Skip to main content

Global variables and Execution profile

Global variables are pre-defined values that are accessible across all test cases, test objects, web service objects, and email configurations in a project. They are used to execute test scripts in multiple and different environments.

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

Global variables example

In Katalon Studio, global variables are defined in execution profiles to configure the testing environment in terms of data and behaviors.

This document shows you how to work with global variables and execution profiles in Katalon Studio.

Create a profile

The following guide shows you how to create a profile to add global variables.

You can create execution profiles to manage global variables based on specific testing purposes..
  1. In the Tests Explorer tab, right-click on Profiles > New > Execution Profile.
    Enter a name for the profile in the New Execution Profile dialog.
  2. In the profile manual view, click Add.
    You need to define the profile content by adding global variables.

  3. Specify details for the variable in the New Variable dialog, then click OK.
  4. The variable is added to the profile accordingly.

You have created a new execution profile with your global variables.

View a profile

Execution profile is provided with Manual view and Script view.

In the Script view, an XML editor is available for adding variables via script. To ensure consistency in testing different environments, you can copy and paste the list of global variables from one profile to another.

Use global variables in test execution

By selecting an execution profile, you can define global variables for executing a test case, test suite, and test suite collection in different scenarios. Katalon Studio uses the default profile by default as indicated on the main toolbar.

In test case and test suite

Select your desired profile from the main toolbar. This setting applies to all test cases and test suites within your project.

In a test suite, you can only select 1 specific profile to apply to all test cases in that test suite. For example, in this test suite, you can execute 3 test cases using the default profile at a time.

global variables in test suite

In test suite collection

In a test suite collection, you can assign which profile to apply to each test suite in the Profile column.

Test suite collection editor

Scope of global variables

The scope of Global variables is applied in a test suite collection (TSC).

Katalon Studio defines global variables in an execution profile. In a test suite collection, you can assign different profiles to each test suite. During the runtime, modifying the value of global variables in one test suite will not impact the values of global variables in other test suites within the TSC.

You can find "Test Suites/New Test Suite (1)" is listed twice in the following screenshot. The first one uses "default," and the second one has "stagging". Any changes made in profile "default" will not impact profile "stagging". These two test suites run independently without affecting each other. This association confirms Global variables and Profile are Test Suite scoped. Test suite collection

For command-line interface (Katalon Runtime Engine )

Select your desired profile in the Profile option of Command Builder.

console profile

You can also manually change the executionProfile argument in the generated command.

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

Set default profile at project level


From Katalon Studio v7.4.2, you can set a default profile at the project level.

A default profile is where you store commonly used global variables. Other profiles can either inherit or override the global variables stored in the default one.

You may have multiple profiles for executing your tests, for instance, staging and production profiles. It would be convenient to set a profile as your default one in every execution of a project.

Right-click on your desired execution profile and select Set as default Execution Profile.

The selected profile becomes a default execution profile for test case, test suite, and test suite collection in that project.

The setting is also applied to Command Builder for Katalon Runtime Engine.

Inherit profile

Profile inheritance reduces your effort spent on modification and recreation of the same global variables in derived profiles. Suppose Katalon Studio does not find variables used in the test within the designated profile (any profiles but default). In that case, it will look into the default profile and use its variables to execute the test.

Commonly used global variables should be stored in the default profile. The following examples illustrate how the profile inheritance feature works.

  • Given the following test case:

  • Execution default profile in use:

    The result is shown as below:

  • Execute staging and production profile with the given test case:

    When executing the staging and production profiles, the name, serverURL, and credential variables are overridden (highlighted in red), while the usage and reference variables are inherited (highlighted in blue) from the global variables in the default profile.

    • Staging profile:

      The result is shown as below:

    • Production profile:

      The result is shown as below: