Verification in IF statement, Katalon marks red when fails

Hiya,

I can’t seem to fix an issue I am having so I hope someone here can help me out.

In one of my scripts I am using an IF statement.
The IF statement verifies an element and if true it will do a few steps and if not it will do nothing and continue the rest of the script.

This all works fine however… When the verification fails and my script continues… Katalon will mark the test as failure because of the verification.
Is there any way for Katalon to NOT mark the test as failed?

Yes, the verification failed, Katalon is right in that. But It is in an IF statement and if it fails I want it to do something else, but I do not want Katalon to mark it red as it will just raise a flag in my report while it isn’t anything to worry about.

Here is my script:

//Go to overview and mark it complete.
if (WebUI.verifyElementText(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/check_Behandelaar’), ‘Nog geen behandelaar bekend’, FailureHandling.CONTINUE_ON_FAILURE)){
WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Optie Faculteit Behandelaar’))
WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Optie Wijzig Faculteit Behandelaar’))
WebUI.setText(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/setText_Wijzig Actor FB Filter’), ‘Verspaandonk-Andreas, Diana’)
WebUI.sendKeys(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/setText_Wijzig Actor FB Filter’), Keys.chord(Keys.ENTER))
WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Wijzig Actor’))
WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Wijzig Actor FB OK’))
} else {
}

WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Optie Toetsing Loket Rechtsbescherming’))
WebUI.click(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/click_Optie Toetsing Loket Rechtsbescherming Compleet’))

WebUI.verifyElementText(findTestObject(‘Page_Home (Docent)/Zaak/Overzicht/check_Status Toetsing Loket Rechtsbescherming’), ‘Compleet’)

Here is my error log

01-21-2020 12:32:28 PM if (verifyElementText(findTestObject(“Page_Home (Docent)/Zaak/Overzicht/check_Behandelaar”), “Nog geen behandelaar bekend”, CONTINUE_ON_FAILURE))

Elapsed time: 1.072s

Actual text ‘’ and expected text ‘Nog geen behandelaar bekend’ of test object ‘Object Repository/Page_Home (Docent)/Zaak/Overzicht/check_Behandelaar’ are NOT matched. (Root cause: com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘Nog geen behandelaar bekend’ of test object ‘Object Repository/Page_Home (Docent)/Zaak/Overzicht/check_Behandelaar’ are NOT matched.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.doCall(VerifyElementTextKeyword.groovy:57)
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.call(VerifyElementTextKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword.verifyElementText(VerifyElementTextKeyword.groovy:72)
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword.execute(VerifyElementTextKeyword.groovy:40)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementText(WebUiBuiltInKeywords.groovy:3647)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementText.call(Unknown Source)
at Zaak (Klacht) Afhandelen.run(Zaak (Klacht) Afhandelen:20)
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.RawTestScriptExecutor.runScript(RawTestScriptExecutor.java:34)
at com.kms.katalon.core.main.RawTestScriptExecutor.doExecute(RawTestScriptExecutor.java:29)
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.runTestCaseRawScript(TestCaseMain.java:151)
at com.kms.katalon.core.main.TestCaseMain$runTestCaseRawScript$0.call(Unknown Source)
at TempTestCase1579606346354.run(TempTestCase1579606346354.groovy:66)
)

Thanks in advance.

Hi
Use FailureHandling.OPTIONAL on the if statement

lol that worked. Thanks for the quick awser :slight_smile: