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 to fail the script after catch?

gligogligo Members
edited November -1 in Sahi - Open Source
I have my script between Try and catch
In catch I make screenshot, if something fails and if catch is invoked.
But I want after this screenshot, the whole script to be marked as failed. Now it is marked as pass. Can I ?

Comments

  • hi gligo
    i think _logAsFailure should do it
  • gligogligo Members
    Yes, I found it _logExceptionAsFailure(e), thank you!
  • gligogligo Members
    Is there any way to fail the script without try - catch block?
    For ex.
    if ($user == undefined) {
    fail the script?
    {
  • you could put in a nonsense statement

    if ($user == undefined) {
    _click(_link("I dont exists, I'm just here to stop testexecution"));
    {
  • narayannarayan Administrators
    You could do

    _fail("My message for failure")
  • gligogligo Members
    Thanks to both of you! Both cases work, but with _fail is more clear in the log and faster.
This discussion has been closed.