Hi,
you have to first define Global Variable with value or null value
`
then in testcase use it
CustomKeywords.'com.global.variables.CreateGlobalVariables.addGlobalVariable'('localURL', 'katalon.com')
println GlobalVariable.localURL
and Keyword is
import internal.GlobalVariable
public class CreateGlobalVariables {
@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
}
}
2019-04-17 16:19:26.877 DEBUG testcase.iniFile - 2: println(localURL)
katalon.com