Katalon Recorder global variables


#1

how to use global variables in katalon recorder (selenium) to use the value of the variables in different tests ?


#2

Hi Fernando,

I don’t think Katalon recorder supports global variables. Recorder only supports basic test cases. You can only use local variables. If you really want to use global variables, you should use the Katalon studio.

Thanks.


#3

I’ve
already solved the problem, if you can use global variables in katalon
recorder, when you have some time I’ll think about how to do it.


#4

I solved this problem by creating a javascript file that contains the global varaible and then I save it in katalon recorder, I create a camando to invoke the varaible. that’s how it works :slight_smile:


#5

Can you share that code with us? :slight_smile:
It is possible to use csv file as well to have a global variables.


#6

Hi @Fernando_Espinoza, it would be nice if you can share your solution as a tips-and-tricks post of sorts for users who are encountering the same problem. Or you can share your solution in more details here and we will compile into a tips-and-tricks post ourselves !

Good day !


#7

Hi, of course if you shortly share a snippet of code and how it works.


#8

You can use the store command as explained here

Command: store
Target: The Value to store e.g. Hello World
Value: The name of the variable to store the value e.g. MyVar

You can view the value of the variable in the Log by using the echo command
Command: echo
Target: ${The name of the variable to output} e.g. ${MyVar}

You can also see the variables and their values by viewing the Variables tab on the recorder.

You can then use the variable in other tests e.g. setting the value of a text box
Command: type
Target: css=input[type=text]#MyTextBoxID
Value: ${MyVar}

Note that you should probably set up your global variables in the first test of your test suite to ensure the values are available for the other tests.


#9

I create a js file that contains the variables, then I just send the varible

a file user-extensions.js is recreated and it is only uploaded in the interface of katalon ide
the file contains the following code for example:

storedVars [“varName”] = “”;
storedVars [“varPass”] = “”;
storedVars [“varBanOw”] = “”;
storedVars [“varPassOw”] = 123 + 5;

Then you get the value of the varible as follows:
Command: click
Target: css = input [type = text] #MyTextBoxID
Value: $ {varName}