Click an element if child element exists (while loop)


I’m pretty new to Katalon Studio, but after some googling and going through the forums, I think have a pretty decent idea of how to achieve what I want to do, but I’m not sure how to deal with the error message I’m getting (posted after the code).

What I’m trying to achieve
I have a website with a grid of items that appear based on a search result. Some of these grid items have a navigation in them, some don’t. I want to click the first item that has this inner navigation.

My code
Integer GridNumber = 1
Boolean Action = false

while (true) {

  String xpathValue = 'div[@id="app"]/div/div[@class="main-content"]/div[3]/div[2]/div[@class="container"]/div/div[@class="grid-items"]/div[' + GridNumber + ']/div/div[@class="product-card__navigation"]'

  TestObject hasNavObject = new TestObject()


  Action = WebUI.waitForElementVisible(findTestObject(hasNavObject), 1, FailureHandling.OPTIONAL)

  if (Action == true) {
  } else {


(ConditionType is imported before this)

The error message
while (true) FAILED.
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.testobject.ObjectRepository.findTestObject() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject) values: [TestObject - ‘’]
Possible solutions: findTestObject(java.lang.String), findTestObject(java.lang.String, java.util.Map)
at Change fabric:44)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)

If I’m following this correctly, try…

WebUI.waitForElementVisible(hasNavObject, ...

and the same with the click, of course.

As Russ mentioned - this is a method definition

boolean waitForElementVisible(TestObject to, int timeout)

You need

TestObject findTestObject(String objectPathInRepository)

to get the test object from the repository.

As soon as you define your TestObject within a test or keyowrd, you don’t need findTestObject(…) anymore. Just pass the object itself to the waitFor (and any other) method

1 Like

Wasn’t more complicated than that. Thanks a lot!

1 Like