Hello,
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 WebUIpublic class FmUI {
@Keyword
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
}
}