Permanently setting a global variable from code

Hi, new Katalon Studio user here.

I am wondering if there is a way to permanently set a global variable from code. Here is my use case:

I’m storing a username and password of the application I’m testing as global variables. These are used for login tests as well as further tests where checks are added to determine if user is logged in before doing other actions. In my test collection I also have a test for changing passwords. In that test, I generate a random string and use it to for the new password. Since other tests will be performed later on, which may require login, I would need to update the global password variable to the new value, otherwise login won’t work.

So my question is, as in the title, is it possible to permanently set a global variable from a test case? If not, are there any plans to support such a functionality in near future? Are there any other good practices in Katalon Studio for how to work with such use cases?

Thanks!

Hello Žan,
just set it:

TC1
println GlobalVariable.testVar
GlobalVariable.testVar = "otherVal"
println GlobalVariable.testVar
TC2
println GlobalVariable.testVar

image.png

1 Like

Andrej Podhajský said:

Hello Žan,
just set it:

TC1

println GlobalVariable.testVar
GlobalVariable.testVar = “otherVal”
println GlobalVariable.testVar


TC2
println GlobalVariable.testVar


  

Thank you, this works for running Test Suites as we’re directly changing the object I presume.

However, would it be possible to actually change the global variable in the Profiles listing, so that it’s changed outside the current execution. For example, if I change the password to a randomly generated string in a TS, but then want to manually use the account later or use it in a secondary TS, the repository with global variables will still hold the previous value.

Perhaps I should be looking towards a data approach for this use case, by using an Excel or MySQL DB for the accounts. In that case, I assume I could change the DB entry permanently (outside execution).

since under hood of Katalon studio is groovy running, you can store and receive things from file, db, basicaly outside Katalon