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.

1 Like‘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")

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))
{‘abc/button_next’), FailureHandling.OPTIONAL)
log.logInfo(" abc " + PageName[i])

		KeywordUtil.markFailedAndStop(" abc "  + PageName[i])