I have a simple thing I’m starting with, I want to see if the text “2018” is present on a page, if it is, I want to show it as a failed step. I have this now, but it keeps showing as passed.
First thing is the “true” in the verifyTextPresent method means you want to use Regular Expression (RegEx). RegEx allows you to do a similar comparison using wildcards. You are not using any wildcard in your text, so I would change the statement to use false, like I do below.
The second thing is you have to use the NOT version of the method, because you want it to fail if the text is present, so if it is not present, then all’s good. However, the failure is that the text is present and we were asking for it to “not be present”. Since the below statement is not true, it fails and you get STOP_ON_FAILURE.
Test Cases/Case2 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify text ‘2018’ is not present
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextNotPresentKeyword.verifyTextNotPresent(VerifyTextNotPresentKeyword.groovy:82)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextNotPresentKeyword.execute(VerifyTextNotPresentKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextNotPresent(WebUiBuiltInKeywords.groovy:1740)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextNotPresent$1.call(Unknown Source)
at Case2.run(Case2:24)
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:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1687824451810.run(TempTestCase1687824451810.groovy:25)
Caused by: com.kms.katalon.core.exception.StepFailedException: Text ‘2018’ is present on page
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextNotPresentKeyword$_verifyTextNotPresent_closure1.doCall(VerifyTextNotPresentKeyword.groovy:77)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextNotPresentKeyword$_verifyTextNotPresent_closure1.call(VerifyTextNotPresentKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more
Did your test script come to inglorious end or did it keep on going? If it came to an inglorious end, then good (FailureHandling.STOP_ON_FAILURE). If it kept on going, huh!
It’s the STOP_ON_FAILURE that causes the test script to “blow up”. To keep on going, you can use either, FailureHandling.CONTINUE_ON_FAILURE, which will show a red error and allow you to isolate the statement if you use the “Only show failed step” icon (on the side of the Log Viewer),
becomes:
or you can use FailureHandling.OPTIONAL, which will show as a yellow warning.
Edit: Lastly, if you don’t use the FailureHandling in the parameters, then the project preferences are used and the default setting is OPTIONAL.