This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/create-global-variables-on-the-fly.html
This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/create-global-variables-on-the-fly.html
Hi - I have used the same code to create a Global Variable dynamically as given below
Keyword definition:
public class Helper {
@Keyword
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’, ‘katalon.com’)
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[31mReason: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
at WSVerification1575556520978.run(WSVerification1575556520978:17)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at
same error, myabe is only a fake help this page