I have located the elemnt using xpath, but it will be changing its position. so i think it can be resolved with directly inputting xpath in the scripts
I ve tried the below script
for (int p=1; p<10;p++)
{
WebElement element1 = WebUiCommonHelper.findWebElement(By.xpath("//div[@id=‘surveylist’]/div/div[p]/div/div//div[@class=‘survey-card-title-text activator truncate tooltipped’]"),30)
if (element1.getText() == “smoke test”)
{
WebUI.executeJavaScript(‘arguments[0].click()’, Arrays.asList(element1))
This is what you can to do easily use XPath in findTestObject.
Create a new custom keyword called TestObjectHelper (or whatever)
public class TestObjectHelper {
public static TestObject getTestObjectWithXpath(String xpath) {
return new TestObject().addProperty('xpath', ConditionType.EQUALS, xpath)
}
}
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)
this was exactly what I was looking for. I use this Testhelper class too.
But when call WebUI.click… I get this error. did I miss something? (just renamed the method in the class)
click(TestObjectHelper.findTestObjectWithXpath(strTestXpath))
2020-11-24 13:55:00.014 ERROR c.k.k.core.main.WSVerificationExecutor - ? Verification FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: TestObjectHelper for class: WSVerification1606222480518
at WSVerification1606222480518.run(WSVerification1606222480518:63)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:146)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:140)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:123)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:115)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:103)
at com.kms.katalon.core.main.TestCaseMain.runWSVerificationScript(TestCaseMain.java:127)
at com.kms.katalon.core.main.TestCaseMain$runWSVerificationScript$0.call(Unknown Source)
at TempTestCase1606222477921.run(TempTestCase1606222477921.groovy:25)