# How to loop through objects

**URL:** <https://forum.katalon.com/t/how-to-loop-through-objects/9798>\
**Category:** Miscellaneous\
**Created:** [March 18, 2018, 10:33pm UTC](https://forum.katalon.com/t/how-to-loop-through-objects/9798 "2018-03-18T22:33:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Anthony](https://forum.katalon.com/u/Anthony)\
**Post date:** [March 18, 2018, 10:33pm UTC](https://forum.katalon.com/t/how-to-loop-through-objects/9798/1 "2018-03-18T22:33:36Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Anthony](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Anthony](https://forum.katalon.com/u/Anthony)\
**Post date:** [March 18, 2018, 11:30pm UTC](https://forum.katalon.com/t/how-to-loop-through-objects/9798/2 "2018-03-18T23:30:04Z")

</div>

I found a solution

```auto
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)
}

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [March 19, 2018, 2:30pm UTC](https://forum.katalon.com/t/how-to-loop-through-objects/9798/3 "2018-03-19T14:30:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anthony](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Anthony](https://forum.katalon.com/u/Anthony)\
**Post date:** [March 19, 2018, 6:00pm UTC](https://forum.katalon.com/t/how-to-loop-through-objects/9798/4 "2018-03-19T18:00:48Z")

</div>

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.
