Local and global variable in katalon Studio.

Global variable in Katalon studio.

What is Local and Global Variable in Katalon Studio? How to define the Global variable in automation with  Katalon Studio.

A global variable in Katalon Studio is a variable which is used globally in the project. For example, If you are going to define a variable as a global variable you can use it in any test case in the project.

 How to define Global variable in katalon studio.

 Step1: Create a test case in katalon. And click on the blue cross sign in the right top corner.

Global variable in katalon studio


Global variable in katalon studio

Step2: Click on the add button.

Step3: Enter variable name, variable type and variable value.

Step4: Click on the Ok.

Step5: Call that global in any test case.

For Example, I am going to print that Global variable on the console.

To use that global variable in katalon you need to call “GlobalVariable.userName


How to define a Local variable in katalon studio. 

Local variable in katalon studio

How to declare Local variable in Katlaon Studio.

 Step 1: Just click on variables and It will switch on variables tab.

Step 2: Click on the Add button. It will add a new variable.

Step 3: Enter the variable name.

Step 4: Select a data type for your variable.

Step 5: Enter the value of the variable.

Now finally your variable is set successfully now you need to call in your test case or where you required in the same test. It’s a local variable so you can not use that variable out of this test case.

How to call Local variable in Katlaon Studio.

Open your script and enter the variable name for example: Like I need to print my variable on katalon studio console.


Example 2:

If you want to add setText in any input field like username of the user at the login page.

By default, It will pass a value like this.

WebUI.setText(findTestObject(‘Page_CURA Healthcare Service/input_username’), ‘John Doe’)

By using variable:

WebUI.setText(findTestObject(‘Page_CURA Healthcare Service/input_username’), userName)

Katalon studio tutorial 7: Local and global variable in katalon Studio