Create Global Variables on the fly

This is a companion discussion topic for the original entry at

Hi - I have used the same code to create a Global Variable dynamically as given below

Keyword definition:

public class Helper {

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


Test Script code :

CustomKeywords.‘Helper.addGlobalVariable’(‘localURL’, ‘’)
println GlobalVariable.localURL

But, I am getting the following error.

2019-03-21 14:56:24.662 e[39mDEBUGe[0;39m e[36mify if an author can be deleted -e[0;39m e[39m3: println(localURL)e[0;39m
2019-03-21 14:56:24.671 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ println(localURL) FAILED.e[0;39m
e[31mgroovy.lang.MissingPropertyException: No such property: localURL for class: internal.GlobalVariable

Pls. kindly help with the same. Thanks.


groovy.lang.MissingPropertyException: No such property: localCookie for class: internal.GlobalVariable

same error, myabe is only a fake help this page