Execution Profile (v5.4+)

Hello @shilpi1

Katalon Studio 7+ supports sharing test artifacts including execution profiles across projects. Read more about new features and improvements in Katalon Studio 7+ here.

Jass

1 Like

Hi, I have a question related to executing a test case by choosing a profile(Ex: qa1).

In my project I have created a profile named"qa1"(addition to the default profile) and I have declared my test case parameters like URL, username and Password.

While executing the test case I have chosen the profile as “qa1” and the test got passed successfully.

However, when I see the console output I could see that the parameters are taken from “Default” profile.

But as I haven’t defined any parameters in default profile, I believe that the console output is supposed to show it as “(qa1)** Username = Admin**" instead "(Default)** Username = Admin**”.

Could you please verify and help me to understand.

Console output:

2019-11-13 22:03:35.549 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-11-13 22:03:35.578 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/Test2
2019-11-13 22:03:36.431 INFO  c.k.katalon.core.main.TestCaseExecutor   - ****(Default)** URL = https://opensource-demo.orangehrmlive.com/**
2019-11-13 22:03:36.474 INFO  c.k.katalon.core.main.TestCaseExecutor   - ****(Default)** Username = Admin**
2019-11-13 22:03:36.509 INFO  c.k.katalon.core.main.TestCaseExecutor   - ****(Default)** Password = admin123**

that message does not means the data was taken from the default profile, but means it has the default value (taken from the selected profile in your case, i suppose you defined them in the variable tab in testcase with global variable type) and it is not overriden (by data binding or calling testcase with variable binding)
you can do a simple experiment, define the same variables but with different values in the default profile and run your test again with the qa1 selected, check which values were used.

@Ibus

I have verified the suggested experiment and I see that it is taking the values(parameters) from intended profile. Thank you for the clarification.

Hi there,
Thanks for this document and it was very help full how to create global variables at run time. I am looking for creating a global variable of Array type so I can use it across my test. How do I create array type variable.

@vtanguturi

You should see an option List in the Value Type drop down

I think your example is for creating variables in default profile. But I am looking for script to run to create global variable for arrays at run time. Something similar to

@Keyword
static void addGlobalVariable(String name, def value) {
GroovyShell shell1 = new GroovyShell()
MetaClass mc = shell1.evaluate(“internal.GlobalVariable”).metaClass
String getterName = “get” + name.capitalize()
mc.‘static’."$getterName" = { -> return value }
mc.‘static’."$name" = value
}

Thanks

@vtanguturi

I haven’t tried this keyword myself. But have you tried to use it to create an array ?

WhateverTheClassIs.addGlobalVariable('yourVar', ['fsafas','fasfsa','fasfsa']);

and in your test case try to

println GlobalVariable.yourVal

Please try to see if it works. Looking at the logic, I suspect it might.

1 Like

Thanks for the help. it worked.

1 Like

Hello,
as asked by lbk, I would like to combine Global variables

Example, I need to define a directory path, and would like to define sub directory path accordingly.

I tried by using ${Share} syntax inside variable value, but it does not retrieve variable (${Share} is not replaced by its value)

Example :

   <GlobalVariableEntity>
      <description></description>
      <initValue>'\\\\sdb02\\Share023\\'</initValue>
      <name>Share</name>
   </GlobalVariableEntity>
   <GlobalVariableEntity>
      <description></description>
      <initValue>'${Share}Interfaces\\out\\SCM_TEST\\'</initValue>
      <name>Share_MySCM_TEST</name>
   </GlobalVariableEntity>

@lbk, did you find a way to combine global variables ?

The doc tells:

Starting from version 7.4.2 , you can configure a default profile at project level.
Right-click on your desired execution profile and select Set as default Execution Profile .

I do not understand what it means setting an Execution Profile as default, how Katalon Studio behaves. The description in this document is not descriptive enough.

On the other hand, at a post for How to centralise common global variables which repeat in different Profile?, @ThanhTo wrote:

During the execution, if Katalon does not find a variable that is used in the test within the designated profile, it’ll look into Default Profile.

Ah, gotcha!

I think ThanhTo’s sentence should be pasted into the official documentation to make it clearer.

2 Likes

Is there a possibility to use global variable inside other global variable

i.e. my URL is changing with different servers so first part of it is global variable + static part + ID which is changing again.

Can I have this as global variable in which I can define parts of URL as per my other global variables and static text

i.e. GlobalVariable.URL which contains --> GlobalVariable.1 + static text + GlobalVariable.2
GlobalVariable.URL = GlobalVariable.1 + static text + GlobalVariable.2

@emir.salihagic Yes, I do it all the time to check our page timestamp.

WebUI.verifyMatch(WebUI.getText(findTestObject(‘myPage/li_LastUpdatedTimeStamp’),
‘Last Updated by ’ + GlobalVariable.gUserName + ’ on ’ + GlobalVariable.gFormattedDate + ’ .*’, true)

Also, if you are going to do some string manipulation, you should attach the toString() method, such as

GlobalVariable.gUserName.toString().lowerCase()

1 Like

Hello All,

We’ve updated the document regarding your concerns over the Profile Inheritance, please read here for more details.

Shin

Hi there, I had a question about parameterizing a GlobalVariable within a test object. I’ve noticed that if I start my global variable with a digit, the functionality does not work as shown. Is this intended? Screenshot of how intended to use this:example - Copy

In Groovy, variables are not allowed to start with a number. (Many programming languages have a similar rule.)

https://www.tutorialspoint.com/groovy/groovy_basic_syntax.htm

Identifiers

Identifiers are used to define variables, functions or other user defined variables. Identifiers start with a letter, a dollar or an underscore. They cannot start with a number. Here are some examples of valid identifiers −

def employeename 
def student1 
def student_name

where def is a keyword used in Groovy to define an identifier.

1 Like

Thanks for the help @grylion54 , I suspected that might of been the case but I didn’t find it in my googling. I must have missed that, thank you.

A post was split to a new topic: How to rename the default profile?