18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Continuing a script even after failure
Hi
Is there a way if we can continue the execution of a test script even after failure at a particular step.
eg We are asserting a value on step 5 of a script and navigating to the next tab at step 6. Assertion fails at step 5. Is there a way in which i can log the error at step 5 and move on to step 6 and complete the script run?
Is there a way if we can continue the execution of a test script even after failure at a particular step.
eg We are asserting a value on step 5 of a script and navigating to the next tab at step 6. Assertion fails at step 5. Is there a way in which i can log the error at step 5 and move on to step 6 and complete the script run?
Answers
In Sahi, the default behavior is in such a way that n the case of failure of assertion (based on your example), Sahi continues the execution and goes to the next line, logging the failure in the process
.
In which version, are you facing the said issue? In Sahi OS 4.4 i.e the latest released Sahi OS version, the script does continue on failure of a particular assertion. I am attaching a sample script for you which will demonstrate the behavior i mentioned above. I have tried running the following script on Latest released Sahi OS and Pro versions.
Also have a look at the following page to know about Sahi Callback functions which will help you perform actions on various points of script life cycle including failure :
If you still have any problems please do let me know.
Regards.
Thanks for the reply. I'm able to work with the assert statements and continue on with the next statements.
While looking into the call back functions at the link you suggested, i stumbled upon the _onScriptError()
Can i use it like this?
Script1
//line 1
function onScriptError($e){
_logExceptionAsFailure($e);
_focusWindow();
_takeScreenShot();
return true; // Forces Sahi to continue execution and not stop at error. Since Sahi Pro V4.3
}
_assertEqual(12,$val); // val is 13
//line 10
Also if this takes a screenshot this way, where would it get stored?
The screenshots are stored in the following folder.
Regards.