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.

Try-catch not working

balasubramanibbalasubramanib Members
edited November -1 in Sahi - Open Source
I'm not able to continue execution after error at (_click(_link("does not exist")). its not Continuing execution of function 2.
but it goes to catch and log error.

I'm following below method

mainFunction() {

func1();
func2();

}

func1() {
try{
_click(_link("Aktivitet"));
_click(_link("does not exist"));
_click(_link("Aktivitet"));

}
catch(error) {
var $ErrMessage = $error.message;
_logException($ErrMessage);
}
}


func2() {
try{
_click(_link("Search"));
_click(_link("submit"));
}
catch(error) {
var $ErrMessage = $error.message;
_logException($ErrMessage);
}
}

Comments

  • Hi Balasubramanib,

    Try with the following script,
    mainFunction() {
    func1();
    func2();
    }
    func1() {
       try{
           _click(_link("Aktivitet"));            
           _click(_link("does not exist")); 
           _click(_link("Aktivitet"));
      }
    catch(error) {
       var $ErrMessage = error;
         _logException($ErrMessage);
      }
    }
    
    func2() {
       try{
           _click(_link("Search"));            
           _click(_link("submit"));
      }
    catch(error) {
       var $ErrMessage = error;
       _logException($ErrMessage);
      }
    }
    

    This might help you.

    Regards,
    Theeran.
  • Still getting same error :)
  • Any update on this??
Sign In or Register to comment.