Estimated reading time: 2 minutes
There are three types of variables supported in Katalon Studio, as below:
|Private variable||A private variable can be referred only within the scope of the test case where it is defined.|
|Local Variable||A public variable can be exposed as the parameter for the test case where it is defined|
|Global Variable||A global variable can be referred anywhere of your project.|
Refer to the subsequence sections for how to define a variable of each type.
Variables defined in Scripting view of Test Cases are classified as private variables. These variables will only be accessible within the scope of your Groovy class. For example:
// x is defined as a variable of String type String x = "Hello"; // y is defined as a variable of int type int y = 5; // The value of the variables are printed to the console println(x); println(y);
You can manage the list of public variables of your test case by using the Variables tab in your Test Case Editor.
Switch to Variables tab of your Test Case. Then click Add.
A new row is added to the variable list. Modify the variable details and save the test case when you’re done.
- Only for version 5.3 and below.
- Since version 5.4 and above, Global Variables are called Execution Profile. For more details, refer to this documentation.
You can manage the list of global variables in your project by using the Global Variables view.
Expand the Global Variable view. Then click Add.
The New variable dialog is displayed. Specify details for the variable then click OK.
The variable will be added to the Global Variable list accordingly.