Top Rounds
| We are Hiring! |

_setRecovery : Recovering from a scenario without try catch ·

Sometimes it is necessary to do some corrective action in case a test fails half way through.
This is different from try-catch because we do not want the script to continue; we just want the state of our system to be restored to a sensible point.

The relevant APIs are:
_setRecovery(fn)
_removeRecovery()

Any function can be assigned to a script as a recovery function.

Once set, if there is an error during execution, the recovery function will be called before the script stops.

Eg.
_navigateTo("http://sahi.co.in/demo/"); function myRecoveryFn(){ _alert("In myRecoveryFn."); // This statement will be alerted in case of script error. } _setRecovery(myRecoveryFn); // Set the myRecoveryFn as recovery function. _click(_link("Link Test")); // Works normally _click(_link("Bad Link")); // This statement fails and causes myRecoveryFn to be called. _alert("done"); // This statement will not be called, because script failed in the last statement.

The recovery function can be removed via _removeRecovery();




---


Top Rounds