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.
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
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.
Thanks for the help. it worked.
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? - #2 by ThanhTo, @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.
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()
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:
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.
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.