verifyElementVisible throws an exception rather than return false;


#1

ready = WebUI.verifyElementVisible(findTestObject(itemName),FailureHandling.CONTINUE_ON_FAILURE) while(!ready){ WebUI.delay(0.5); ready = WebUI.verifyElementVisible(findTestObject(itemName),FailureHandling.CONTINUE_ON_FAILURE) }

I want to use this instead of the waitFor API

but an exception raised like bellow(when I want to verify if it is visible,but throws an exception said it is not visible,rather than return a false):

est Cases/disableAcct FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/Page_/btn_edit' is NOT visible at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32) at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65) at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.doCall(VerifyElementVisibleKeyword.groovy:83) at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.call(VerifyElementVisibleKeyword.groovy) at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:21) at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.verifyElementVisible(VerifyElementVisibleKeyword.groovy:97) at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.execute(VerifyElementVisibleKeyword.groovy:67) at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53) at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementVisible(WebUiBuiltInKeywords.groovy:358) at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementVisible$6.call(Unknown Source) at Script1539264007216.waitItemReady(Script1539264007216.groovy:92) at Script1539264007216$waitItemReady.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at Script1539264007216.run(Script1539264007216.groovy:55) at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183) at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108) at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294) at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285) at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264) at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256) at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90) at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149) at TempTestCase1539679995296.run(TempTestCase1539679995296.groovy:22) at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263) at groovy.lang.GroovyShell.run(GroovyShell.java:518) at groovy.lang.GroovyShell.run(GroovyShell.java:507) at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653) at groovy.ui.GroovyMain.run(GroovyMain.java:384) at groovy.ui.GroovyMain.process(GroovyMain.java:370) at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129) at groovy.ui.GroovyMain.main(GroovyMain.java:109) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131) )


#2

it’s returning value … check following code:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIWebUI.openBrowser('file://C:/Users/s2ppun/src/html/hello.html')if(!WebUI.verifyElementPresent(findTestObject('Object Repository/__Sandbox/HelloFile/notExistingOne'), 3, FailureHandling.OPTIONAL)){	println '***** OPTIONAL'} if(!WebUI.verifyElementPresent(findTestObject('Object Repository/__Sandbox/HelloFile/notExistingOne'), 3, FailureHandling.CONTINUE_ON_FAILURE)){	println '*****  CONTINUE'} if(!WebUI.verifyElementPresent(findTestObject('Object Repository/__Sandbox/HelloFile/notExistingOne'), 3, FailureHandling.STOP_ON_FAILURE)){	println '*****  STOP'}

console:

10-16-2018 11:34:45 AM - [INFO]   - Navigating browser to: 'file://C:/Users/s2ppun/src/html/hello.html'10-16-2018 11:34:45 AM - [PASSED] - Browser is opened with url: 'file://C:/Users/s2ppun/src/html/hello.html'10-16-2018 11:34:45 AM - [END]    - End action : openBrowser10-16-2018 11:34:45 AM - [START]  - Start action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, OPTIONAL)))10-16-2018 11:34:45 AM - [INFO]   - Finding Test Object with id 'Object Repository/__Sandbox/HelloFile/notExistingOne'10-16-2018 11:34:45 AM - [INFO]   - Checking object10-16-2018 11:34:45 AM - [INFO]   - Checking timeout10-16-2018 11:34:45 AM - [INFO]   - Finding web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' in '3' second(s)10-16-2018 11:34:48 AM - [INFO]   - Unable to find the element located by 'By.xpath: id('9999')'. Please recheck the objects properties to make sure the desired element is located. 10-16-2018 11:34:48 AM - [INFO]   - Begin finding web elements by trial and error method10-16-2018 11:34:48 AM - [INFO]   - Web element found by trial and error method is not used because we can't guarantee it reflects the intended element. See detailed troubleshooting guide for common issues: https://docs.katalon.com/x/awXR10-16-2018 11:34:49 AM - [WARNING] - com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' not found10-16-2018 11:34:49 AM - [START]  - Start action : Statement - println("***** OPTIONAL")***** OPTIONAL10-16-2018 11:34:49 AM - [END]    - End action : Statement - println("***** OPTIONAL")10-16-2018 11:34:49 AM - [END]    - End action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, OPTIONAL)))10-16-2018 11:34:49 AM - [START]  - Start action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, CONTINUE_ON_FAILURE)))10-16-2018 11:34:49 AM - [INFO]   - Finding Test Object with id 'Object Repository/__Sandbox/HelloFile/notExistingOne'10-16-2018 11:34:49 AM - [INFO]   - Checking object10-16-2018 11:34:49 AM - [INFO]   - Checking timeout10-16-2018 11:34:49 AM - [INFO]   - Finding web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' in '3' second(s)10-16-2018 11:34:52 AM - [INFO]   - Unable to find the element located by 'By.xpath: id('9999')'. Please recheck the objects properties to make sure the desired element is located. 10-16-2018 11:34:52 AM - [INFO]   - Begin finding web elements by trial and error method10-16-2018 11:34:52 AM - [INFO]   - Web element found by trial and error method is not used because we can't guarantee it reflects the intended element. See detailed troubleshooting guide for common issues: https://docs.katalon.com/x/awXR10-16-2018 11:34:52 AM - [FAILED] - com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' not found10-16-2018 11:34:52 AM - [START]  - Start action : Statement - println("*****  CONTINUE")*****  CONTINUE10-16-2018 11:34:52 AM - [END]    - End action : Statement - println("*****  CONTINUE")10-16-2018 11:34:52 AM - [END]    - End action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, CONTINUE_ON_FAILURE)))10-16-2018 11:34:52 AM - [START]  - Start action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, STOP_ON_FAILURE)))10-16-2018 11:34:52 AM - [INFO]   - Finding Test Object with id 'Object Repository/__Sandbox/HelloFile/notExistingOne'10-16-2018 11:34:52 AM - [INFO]   - Checking object10-16-2018 11:34:52 AM - [INFO]   - Checking timeout10-16-2018 11:34:52 AM - [INFO]   - Finding web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' in '3' second(s)10-16-2018 11:34:55 AM - [INFO]   - Unable to find the element located by 'By.xpath: id('9999')'. Please recheck the objects properties to make sure the desired element is located. 10-16-2018 11:34:55 AM - [INFO]   - Begin finding web elements by trial and error method10-16-2018 11:34:55 AM - [INFO]   - Web element found by trial and error method is not used because we can't guarantee it reflects the intended element. See detailed troubleshooting guide for common issues: https://docs.katalon.com/x/awXR10-16-2018 11:34:55 AM - [FAILED] - com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' not found10-16-2018 11:34:55 AM - [FAILED] - Unable to verify object 'Object Repository/__Sandbox/HelloFile/notExistingOne' is present (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' not found)10-16-2018 11:34:55 AM - [FAILED] - Test Cases/__Sandbox/New Test Case Text from hidden div FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/__Sandbox/HelloFile/notExistingOne' located by 'By.xpath: id('9999')' not found	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32)	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementPresentKeyword$_verifyElementPresent_closure1.doCall(VerifyElementPresentKeyword.groovy:85)	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementPresentKeyword$_verifyElementPresent_closure1.call(VerifyElementPresentKeyword.groovy)	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:21)	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementPresentKeyword.verifyElementPresent(VerifyElementPresentKeyword.groovy:92)	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementPresentKeyword.execute(VerifyElementPresentKeyword.groovy:68)	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(WebUiBuiltInKeywords.groovy:1418)	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementPresent$0.call(Unknown Source)	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)	at Script1539600713936.run(Script1539600713936.groovy:27)	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90)	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)	at TempTestCase1539682480903.run(TempTestCase1539682480903.groovy:22)	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)	at groovy.lang.GroovyShell.run(GroovyShell.java:518)	at groovy.lang.GroovyShell.run(GroovyShell.java:507)	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)	at groovy.ui.GroovyMain.run(GroovyMain.java:384)	at groovy.ui.GroovyMain.process(GroovyMain.java:370)	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)	at groovy.ui.GroovyMain.main(GroovyMain.java:109)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:498)	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131))10-16-2018 11:34:55 AM - [END]    - End action : Statement - If (!(com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementPresent(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/HelloFile/notExistingOne), 3, STOP_ON_FAILURE)))10-16-2018 11:34:55 AM - [END]    - End Test Case : Test Cases/__Sandbox/New Test Case Text from hidden div

as you can see OPTIONAL and CONTINUE text are there so, value was returned


#3

Hi everyone,

This bug fix is included in Katalon Studio 7.0.0. Please first check out the release note and click here to download if you want to try version 7.0.0 (beta) in advance.

Happy Testing!

Jass