Katalon Recorder - Continue on Failure

Hi everybody ! Do you know how to handle the failure on Katalon Recorder ? Like Continue on failure.

thanks !

Do you mean when you are using an assert command?

If so, there is usually a corresponding verify command which will continue executing the test script.

1 Like

Hi, I’m affraid that is not possible to simple continue testcase after failure. In many testcase’s if it’s fail on some command even if You will make him to continue it can couse errors in some next command.

But… :slight_smile:
If you want your testcase to do something that is not nessessary for Your testcase try to use runScript command and JS code in it. So if syntax of your JS code will be ok it will go in Katalon with no problem and it will be green.
And inside this JS you can for example create variable “error” and depend on what this script do it will set this variable to true or false.

But… :smiley:
Be aware that You shouldn’t put there any critical things in it without any feedback from code.
For example:
Inside this JS code You check if some element exist on the page which is tottally nessesary to exist but there is no such element on page. Katalon will run this script and make it green and go forward. So You will not have any feedback what happen - wheater this element exist or not. In such situation remember to return some variable to Katalon so You will have it in Variables tab and in log.

Just to add to @Piotr’s answer, JavaScript has try..catch statements which you can use to trap any unexpected errors thrown from JavaScript code and handle gracefully so the test does not fail.


Here’s an example

runScript | try {document.allert("This is an unexpected error"); return "Success";} catch (err) {return err.message;} | result |
echo | ${result} | |
runScript | document.allert("This is an unexpected error"); return "Success"; | result |
echo | ${result} | |

and here’s the Log

[info] Executing: | runScript | try {document.allert("This is an unexpected error"); return "Success";} catch (err) {return err.message;} | result |
[info] Store 'document.allert is not a function' into 'result'
[info] Executing: | echo | ${result} | |
[info] Expand variable '${result}' into 'document.allert is not a function'
[info] echo: document.allert is not a function
[info] Executing: | runScript | document.allert("This is an unexpected error"); return "Success"; | result |
[error] Error: TypeError: document.allert is not a function
[info] Time: Fri Feb 15 2019 10:55:51 GMT+0000 (Greenwich Mean Time) Timestamp: 1550228151515
[info] Test case failed

Note that the first two statements complete and the result variable contains the error message, but the test case fails on the third line.



That is a simple but effective trick to simulate continue on failure.
It would be awesome if you make it into a tip and trick post and just quote the link for future questions :grin:

Regards !

1 Like