Passing integer value to global parameters during console execution


I had created a gloabl variable in profile with ‘Value Type’ as Number and assigned it a number , let say 15.

I am trying to executeg scripts through console mode and wish to override this global parameter value with number 3 and for this I am using argument as


I am using this variable whenever I am calling waitForElementVisible or waitForElementPresent methods.
But, during script execution, an error occurred whenever the above mentioned ketword executed because it is interpreting ‘3’ as string not a number and throws an error like

groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementPresent() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, java.lang.String)

Question is, if passing a number to global variable like -g_timeToWaitForElement=3 is not correct way then how I can do this without error?


Assuming that your code is allowing for the case where the value is an integer (and you want to continue to support that case), then…

value.toString().toInteger() // 10 -> "10" -> 10, "5" -> "5" -> 5

Will that help?

1 Like

i think this is a known issue still ignored.
as far as i remember this happens at least with data driven testing, e.g binding a variable which apparently is a valid number from the point of a sql select, katalon pass it as a string.
same may happen when overriding a certain global variable at runtime through cli options.

this has to be explored a bit.
my two cents, it is a valid bug, the cli just pick up whatever value passed to certain option as string, being unaware of the data type expected.
therefore the lazzy approach, no validation implemented.

in the meantime, the workaround proposed by @Russ_Thomas should work.

A slightly amended sample code:

    GlobalVariable.timeToWaitForElement.toString().toInteger()    // 10 -> "10" -> 10, "5" -> "5" -> 5

nothing new.

Thanks for the solution but now I need to do lot more work to replace GlobalVariable.timeToWaitForElement with GlobalVariable.timeToWaitForElement.toString().toInteger() in around 100 scripts :confounded:

Well, you have to “thanks” to the development team for a silly implementation of the command-line options parsing.

Just do it. Possibly you can finish it in a few hours.

Good-old shell command (sed etc) would help you edit 100 scripts in a few seconds.