18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Unable to catch exception using assert api
Hi,
Please find the below code I am trying to execute, (Using Build: 2010-08-20)
var $myPath = "C:\\Log_201Oct23.log";
try{
_assertTrue(1==2); // or any assert API
_writeFile("TEST PASS",$myPath);
}catch(e){
_writeFile("TEST FAIL",$myPath);
}
Even though the assert fails, the control does not go into the catch block (as expected) !
Under logs I see the assertion failing in red colour.
Please find the below code I am trying to execute, (Using Build: 2010-08-20)
var $myPath = "C:\\Log_201Oct23.log";
try{
_assertTrue(1==2); // or any assert API
_writeFile("TEST PASS",$myPath);
}catch(e){
_writeFile("TEST FAIL",$myPath);
}
Even though the assert fails, the control does not go into the catch block (as expected) !
Under logs I see the assertion failing in red colour.
This discussion has been closed.
Comments
try {
_assertExists(_cell($docType, _near(_link("Type[1]"))));
} catch (e) {
_assertExists(_cell("*Not specified", _near(_link("Type[1]"))));
_logException("Doc Type not found...");
}
Perhaps I'm missing something?
Thanks,
Brian
For the user, _asserts do not throw an exception. (Sahi internally catches the assert exceptions, logs them and goes on to the next step.)
If you want conditional behaviour, please see if use can use an "if" condition.
Regards,
Narayan
Brian