I have this object repo that will display the number. So I want to capture the output and compare it. But how to declare it? Already search but nothing I found.
What is that?
Capture what? Compare it with what?
if(findTestObject(‘Object Repository/Page_Tic-Tac-Toe - Play retro Tic-Tac-Toe o_f67da4/span_0’)<0 )
For example like this one. I want to compare it with the value 0. And it will the error
groovy.lang.GroovyRuntimeException: Cannot compare com.kms.katalon.core.testobject.TestObject with value ‘TestObject - ‘Object Repository/Page_Tic-Tac-Toe - Play retro Tic-Tac-Toe o_f67da4/span_0’’ and java.lang.Integer with value ‘0’
findTestObject()
returns a reference to a Test Object stored in the Katalon Object Repository.
A Test Object stores information about an element on a web page – in your case, that appears to be an HTML <span>
element.
So, based on your code, it appears you want something like…
getText(findTestObject(...))
If you want to do a numeric comparison, you will need to convert the String
returned by getText()
to numeric type like int
.
Thats what I want to do it but I dont know how !! Thanks
How about:
def myVal = Integer.parseInt(WebUI.getText(findTestObject('Page_Tic-Tac-Toe - Play retro Tic-Tac-Toe o_f67da4/span_0'))
WebUI.comment("my value is ${myVal}")
if (myVal < 0) {
...
}