18 January 2026:


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

hbabbarhbabbar Members
edited August 2013 in Sahi - Open Source
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?

Answers

  • Pratyush_TytoPratyush_Tyto Members
    edited August 2013
    Hi Himanshu,

    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.
    _navigateTo("http://sahi.co.in/demo/training/login.htm");
    _setValue(_textbox("user"), "test");
    _setValue(_password("password"), "secret");
    _click(_submit("Login"));
    _assertEqual("5", _getValue(_textbox("q")));
    _setValue(_textbox("q"), "5");
    _assertEqual("5", _getValue(_textbox("q")));
    

    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 :
    http://sahi.co.in/w/sahi-call-back-functions
    

    If you still have any problems please do let me know.

    Regards.
  • Hi Pratyush

    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?
  • Hi Himanshu,
    The screenshots are stored in the following folder.
    <path_to_your_sahi_pro>/userdata/logs/playback
    

    Regards.
Sign In or Register to comment.