How to use findTestObject() in CustomKeywords?

I would like to code a function which can find a screen in my web application and return true if it find it.

I wanted to create a customKeyword to do that, but I cannot find a way to use the function findTestObject() in my customKeyword - I get an error :

Caused by: groovy.lang.MissingMethodException: No signature of method: test.common.FmUI.findTestObject() is applicable for argument types: (java.lang.String) values: [Header Menu/Barre de Titre - HFxiii]
at test.common.FmUI.findAlreadyOpenScreen(fmUI.groovy:94)
… 14 more

How could I code a function which returns true or false and use this findTestObject() ?

package test.common

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

public class FmUI {

public boolean findAlreadyOpenScreen(String screenTitle) {

  TestObject titre_ecran = findTestObject('Header Menu/Barre de Titre - HFxiii')

  String xpath_titre_ecran = ('//div[contains(@style,"visibility: visible")]/div[@class="dijitDialogTitleBar"]//*[contains(text(),"' +
  screenTitle) + ' -")]'

  println("xpath barre de titre : " + xpath_titre_ecran)

  titre_ecran.setSelectorValue(SelectorMethod.XPATH, xpath_titre_ecran)

  // tant que l'on ne trouve pas le titre voulu, on ferme les fenetres
  // quand on ne trouve plus de fenetre, on sort
  while (WebUI.waitForElementVisible(findTestObject('Object Repository/Authentification/Page_Reflex - QCSGERFX023/img_R'),5)) {
  	if (WebUI.waitForElementClickable(screenTitle, 1)) {
  		return true //fenetre trouvée !
  	WebUI.doubleClick(findTestObject('Object Repository/Authentification/Page_Reflex - QCSGERFX023/img_R'))
  // plus de fenetre ouverte => fenetre non trouvée
  return false


The complaint from Katalon is about your use of the method and the types of the arguments you’re passing into it. For reasons I’m unaware, the system thinks you have a findTestObject() method supplied by the class test.common.FmUI.

findTestObject() is usually supplied statically by Katalon, as in this import statement:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

Until you fix that (or explain why it’s happening) it’s hard to attest to why the error occurs.

To sum up - the compiler is complaining about your arguments types. Can’t say much more than that.

hello Russ_Thomas

as you suggested, I just had to use this import in order to make it working :

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

It seem this import is not added automatically by Katalon when I create CustomKeyword, so I just had to add it manually.

Thank you

1 Like

Je suis tres heureux (? my high school Francais is over half a century old :crazy_face: )

Sentence “Je suis heureux” is still understandable by me as french language has not changed so much for the last 50 years :joy:

1 Like

I wish I could say the same about me :frowning: