What can use to store a variable and use it in another script?

what can use to store a variable and use it in another script?

You can use Global Variables to store a variable and use it in another script. Global Variables can be used across any test cases in a project. To create a Global Variable, follow these steps:

  1. Create a global variable in your profile file. Check here (Having more than 2 record in the data file messes the recordings)

To use the Global Variable in your script, you can call it like this:

GlobalVariable.variable_name

For more information on Global Variables, refer to the Global Variables and Execution Profile (https://docs.katalon.com/docs/create-tests/data-driven-testing/global-variables-and-execution-profile) documentation.

I want to store a variable from the first script, what command should i use?

Into what do you want to “store” a variable?

into Execution Profile on disk? — Unfortunately you can’t.

Store the value into a variable to compare it in another page.

(1) You want to declare a GlobalVariable named “message” of type String in the “default” Execution Profile.

(2) You want to create a Test Case named “TC1”. In there you want to set a value to the GlobalVariable.message with value “Hello, world!”

(3) You want to create a Test Case named “TC2”. In ther you want to print the value of the GlobalVariable.message

(4) You want to create a Test Suite named “TS1”. You want to put TC1 and TC2 into TS1

(5) You want to run the TS1. Then you will see the text “Hello, world!” printed. The text was set by TC1, and the text was printed by TC2.

This proves that the GlobalVariable.message was shared by both TC1 and TC2.

2 Likes