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.
How to perform exceptional statements, if text assertion fails?
Hi,
In my script, I want to verify some text messages as well as successful execution of script. If verification & execution is successful, I want to set flag as 1, if it fails, I want to set 0 as flag.
I am trying to use "try catch" method with _assertEqual() API, but it doesn't work as _assertEqual does not return anything and doesn't execute the catch(e) part.
Below is my example code:
It does not set flag as '0', if text assertion fails.
Please help, how to do this?
In my script, I want to verify some text messages as well as successful execution of script. If verification & execution is successful, I want to set flag as 1, if it fails, I want to set 0 as flag.
I am trying to use "try catch" method with _assertEqual() API, but it doesn't work as _assertEqual does not return anything and doesn't execute the catch(e) part.
Below is my example code:
var $flag = 1;
try
{
_click(_link("abc"));
_setvalue(_textbox("name"), "xyz");
_assertEqual("Name changed successfully.", _getText(_div("successmessage")));
$flag = 1;
}
catch(e)
{
$flag = 0;
}
It does not set flag as '0', if text assertion fails.
Please help, how to do this?
Comments
as far as I know, _asserts return a boolean. Try:
Regards
Wormi
Yes, it returns "true" if assertion succeeds, but what if it fails? It does not return anything on failure. (This is what I observed).