How to loop through objects

I am trying out Katalon and attempting to loop through a list of objects.
I am stuck at an error, can somebody tell me what I am doing wrong here please?

This is the error:

Test Cases/bbc.co.uk FAILED because (of) groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject) values: [TestObject - ‘Object Repository/Page_BBC - Home/a_Homepage’]

And this is the code I am using, the objects all exist on the page:

homepage = findTestObject('Page_BBC - Home/a_Homepage')
iplayer = findTestObject('Page_BBC - Home/a_iPlayer')
more = findTestObject('Page_BBC - Home/a_More')
def list = [homepage, iplayer, more]
for (def item : list) {
WebUI.verifyElementPresent(item)
}

Thank you

I found a solution

homepage = 'Page_BBC - Home/a_Homepage'
iplayer = 'Page_BBC - Home/a_iPlayer'
more = 'Page_BBC - Home/a_More'
def list = [homepage, iplayer, more]
for (def item : list) {
log.logInfo(item)
    WebUI.verifyElementPresent(findTestObject(item), 0)
}

Hi Anthony

You have discovered what I have learned in the month or so I’ve been using Katalon (Groovy and WebDrivers). Delay until as late as possible turning your Object repository items into TestObjects. And even then, sometimes they can go astray.

I wish someone would improve how “finding” works such that test cases can be made much more robust.

If anyone else here has developed a strategy that works better than 99% of the time in dense, javascript-rich web pages and like to offer up their methods, I’d really appreciate it!

Russ

1 Like

I was suprised to find out that turning the test objects in to variables via the UI variables tab and then attempting to use them also came up with the same type of error.