Katalon Studio - Script for change profile and value global variable

Hi. I’m begginer for Katalon Studio
I am using one profile (STAGE) for Web testing.
In it, I include global variables such as
Admin - (name, lastname, dob, phone, etc.)
Moderator - (name, lastname, dob, phone, etc.)
User
etc.
I would like to replace one profile file all over Test Suits to replace global variables such as name, lastname etc.
Is it possible? I don’t want a solution, but guide me on how to write such a script.

Hi, not quite sure what you’re asking for?
Do you want an easy way to update all the values in a single profile/global variables because you have lots and you don’t want to click and edit on each individually?
Or do you want to refer to a data source eg an Excel file? This could be mapped at test suite level.
Or do you want to have different global variable values for different purposes? Eg either different environments or different iterations in same environment? In which case, see https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html#use-a-profile perhaps
Cheers Dan

@ukaaszk

Look at Test Suite Collection.

When you make a Test Suite Collection, you can associate each Test Suite with a Execution Profile of your choice.

My custom solution is also available.

This keyword provides a keyword “loadExecutionProfile()”, with which you can load any number of Execution Profiles in a Test Case run. GlobalVariables are dynamically overwritten with the values loaded by this keyword, like this:

import com.kazurayam.ks.globalvariable.ExecutionProfilesLoader

new ExecutionProfilesLoader().loadProfile("ProductionEnv")

println "GlobalVariable.URL=" + GlobalVariable.URL

or this:

CustomKeywords."com.kazurayam.ks.globalvariable.ExecutionProfilesLoader.loadProfile"("ProductionEnv")

println "GlobalVariable.URL=" + GlobalVariable.URL

The goodness of this keyword is that it enables the modularisation of Execution Profiles.

What is “modularisaztion of Execution Profile”?

Say, you have 6 GlobalVariables in a single Execution Profile now.

  • var1=foo1
  • var2=foo2
  • var3=foo3
  • val1=bar1
  • val2=bar2
  • val3=bar3

Now you want to assign new value to valX. You need to create 2nd Execution Profile like this:

  • var1=foo1
  • var2=foo2
  • var3=foo3
  • val1=baz7
  • val2=baz8
  • val3=baz9

This would work, but looks stupid. You need to repeat writing `var1=foo1’ in 2 Execution Profiles.

Why you have to repeat writing var1=foo1 in multiple Execution Profiles?

It is because, Katalon Studio asks you to choose only 1 Execution Profile to run your Test Case/Test Suites. Katalon Studio does not provide a way for you to load 2 or more Execution Profiles.


My “ExecutionProfilesLoader” enables you to load 2 or more Execution Profiles for a single Test Case execution.

With it you can split the above example Global variables into 3 groups.

  1. Execution Profile “GroupA”
  • var1=foo1
  • var2=foo2
  • var3=foo3
  1. Execution Profile “GroupB”
  • val1=bar1
  • val2=bar2
  • val3=bar3
  1. Execution Profile “GroupC”
  • val1=baz7
  • val2=baz8
  • val3=baz9

and your test case will choose 2 groups amongst 3, and load them with the ExecutionProfilesLoader.

You can create as many Execution Profiles as modules as you want. For example, in one of my testing project I created 16 Execution Profiles, and choose 5 out of 16 to apply to a single run of Test Suite. This enabled me significant flexibility of configuring the project.

Hi kazurayam
I’m unsure about the statement above. Based on tests I have done, as long as you have all your variables in the “default” profile and only new or changed values in a second profile (or third etc), then based on execution settings you will see:

  • Default profile - uses all variables defined
  • UAT profile - uses all “Default” profile variables, unless overridden by amended values in “UAT” profile

This means that you don’t need to keep writing ‘var1=foo1’, because it will be inherited from Default.
Please let me know if I’m missing something as it seems like this would save time. Cheers Dan

Yeah, I forgot the “default”. My mistake.

I would restate: the goodness of my approach is that it makes me possible to load 3 or more Execution profiles.

Yes I want to update all the values. Now I change manualy but I wonder if you can swap values random automatically
like:
Admin name: Jacob
Lastname: Wander
Now i want to one click, and name, lastname was change in global variable
And then I can run next test case.

Cheers, didn’t want to take away from all the other good stuff you have provided (which I will try to play with)! :grinning:

Suggest you can look into data driven testing (maybe https://dzone.com/articles/data-driven-testing-approach-with-katalon-studio) as well

With a combination of Data Driven testing (Excel as a data source) and my ExecutionProfileLoader (loading multiiple Execution Profiles), you can enjoy good flexibility of configuring a Katalon test project. See the following description of my project.

What I did in my project:

  1. I have a big Excel book, which contains 40 sheets, each of which contains 150 rows where URL and other parameters are written. In the book file, I have 6000 URL listed as canditate to test. This Excel book is multi-purposed (for business administration, for customer relationship management etc, not only for QA activities) so that I am not allowed to change it at all. The book is just given to me.
  2. However a list 6000 URLs list too large to test at a time; it takes too long time: it may take 24hours and more.
  3. Therefore I needed to select a set of URLs (for example 180 URLs) to verify in a particular run of test script.
  4. In order to express a criteria of URL selection, I made 5 Execution Profiles with GlobalVariables.
  5. My test read the maximum list of 6000 URL from Excel, and read selection criteria from 5 Profiles (read them using ExecutionProfilesLoader), apply a custom logic to make a smaller list of URLs to test. Then my test script consumes the list and inspect those URLs. It would take only 20 minutes; far shorter than 24hours of long run.