[Mobile] Verify Element Exist


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/mobile-verify-element-exist.html

This method is returning stepfailed exception.

12-04-2019 02:50:26 PM if (verifyElementExist(findTestObject(“MobileHomePageObjects/android.widget.TextView0 - HSE Observation”), 6) == true)

Elapsed time: 24.086s

Failed to check for element ‘Object Repository/MobileHomePageObjects/android.widget.TextView0 - HSE Observation’ exist (Root cause: com.kms.katalon.core.exception.StepFailedException: Element ‘Object Repository/MobileHomePageObjects/android.widget.TextView0 - HSE Observation’ not found
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)
at com.kms.katalon.core.mobile.keyword.builtin.VerifyElementExistKeyword$_verifyElementExist_closure1.doCall(VerifyElementExistKeyword.groovy:77)
at com.kms.katalon.core.mobile.keyword.builtin.VerifyElementExistKeyword$_verifyElementExist_closure1.call(VerifyElementExistKeyword.groovy)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
at com.kms.katalon.core.mobile.keyword.builtin.VerifyElementExistKeyword.verifyElementExist(VerifyElementExistKeyword.groovy:80)
at com.kms.katalon.core.mobile.keyword.builtin.VerifyElementExistKeyword.execute(VerifyElementExistKeyword.groovy:64)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.verifyElementExist(MobileBuiltInKeywords.groovy:656)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$verifyElementExist$0.call(Unknown Source)
at mobile.run(mobile:22)
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.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1575451192295.run(TempTestCase1575451192295.groovy:23)
)

If you want to get the return value if the keyword fails, please add FailureHandling.OPTIONAL to the method call, like this:

verifyElementExist(findTestObject(“MobileHomePageObjects/android.widget.TextView0 - HSE Observation”, FailureHandling.OPTIONAL), 6) == true

groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.testobject.ObjectRepository.findTestObject() is applicable for argument types: (java.lang.String, com.kms.katalon.core.model.FailureHandling) values: [login/permission_allow_button, OPTIONAL]

FailureHandling.OPTIONAL in the wrong position, its after the timeout
e.g
verifyElementExist(findTestObject(“MobileHomePageObjects/android.widget.TextView0 - HSE Observation”), 6, FailureHandling.OPTIONAL) == true