CS agents will respond to tickets via forum instead of private helpdesk to support other users with similar issues.

how to print custom message in failure handling

I have a line of code including "FailureHandling.STOP_ON_FAILURE" if that statement fails i want to print some message [note: only in case of step fails]
How to achieve this.



  • Use rather FailureHandling.OPTIONAL and add to a next line:

    It'll fail a test with a custom message in next step, you can't add a message to STOP_ON_FAILURE option.

  • pkpk
    edited October 11

    WebUI.click(findTestObject('abc/button_next'), FailureHandling.OPTIONAL)

    //if above statement fails then the this message will print
    KeywordUtil.markFailedAndStop(" Next button does not click on abc page)

    but markFailedAndStop statement is always executing even upper statement is true. HI just need to print message only when upper statement doesn't execute. CAN YOU PLEASE HELP IN THIS. THANKS

  • You have to wrap markFailed method in condition block. Then, it'll be executed only when element is not present/clickable

    if(!WebUI.verifyElementClickable(findTestObject('abc/button_next'), FailureHandling.OPTIONAL)) {
    KeywordUtil.markFailedAndStop(" Next button does not click on abc page")
  • pkpk
    edited October 12

    Thanks once gain Melocik. I also derived another way from your hint. Which is very much similar to your work.

    if(WebUI.verifyElementClickable(findTestObject('abc/button_next1'), FailureHandling.OPTIONAL))
    WebUI.click(findTestObject('abc/button_next'), FailureHandling.OPTIONAL)
    log.logInfo(" abc " + PageName[i])

            KeywordUtil.markFailedAndStop(" abc "  + PageName[i])
Sign In or Register to comment.