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.

How can I _fail() from a browser action?

mattkrusemattkruse Members
edited May 2013 in Sahi - Open Source
I have a function in <browser></browser> tags which runs in the browser. When I detect a problem in this function, how can I trigger the test script to fail? There is no _fail() or even _logExceptionAsFailure() functions in the browser action API!

Thanks,

Matt

Answers

  • Hi mattkruse,

    Please have a look at the below script,

    _navigateTo("http://sahi.co.in/demo/training/";);
    _setValue(_textbox("user"), "sahi");
    _setValue(_password("password"), "sahi");
    _click(_submit("Login"));
    if(_isVisible(_div("Invalid username or password")))
    {
    _log("Invalid username or password", "failure");
    _fail("Invalid username or password");
    }

    Also plz refer http://sahi.co.in/w/_log

    Hope this may help you.

    Regards,
    Umashankar
  • That is not a browser script. That is a normal script. I'm talking about something that is wrapped in <browser></browser> tags, where _fail() is not available.

    I'm trying to hook a failure case into a function I've written that executes on every page load. See:
    http://sahi.co.in/forums/discussion/4858/how-can-i-run-a-function-on-every-page-load#Item_2

    This script runs in the browser on page load and checks for some error conditions. Since Sahi doesn't provide anything that automatically runs on every page load, I had to hack it in.
Sign In or Register to comment.