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 determine which error occured...
I have a piece of code that checks for errors.
I define a couple of possibilities in the function.
How can I determine which of the items actually caused the error?
Code:
var $verify = function(){
var $error = _getText(_div("number"));
var $Error0 = "Number already exisits on our system.";
var $Error1 = "Number Must Be a valid ******";
var $Error2 = "Cannot be left blank!";
if ($Error0 || $Error1 || $Error2){
_fail(????);
}
};
I define a couple of possibilities in the function.
How can I determine which of the items actually caused the error?
Code:
var $verify = function(){
var $error = _getText(_div("number"));
var $Error0 = "Number already exisits on our system.";
var $Error1 = "Number Must Be a valid ******";
var $Error2 = "Cannot be left blank!";
if ($Error0 || $Error1 || $Error2){
_fail(????);
}
};
Best Answer
-
Hi Orrin,
What what I understand of your requirement, the div "number" displays various error messages.
Then the following code should solve your problem.
var $verify = function(){
var $error = _getText(_div("number"));
var $Error0 = "Number already exisits on our system.";
var $Error1 = "Number Must Be a valid ******";
var $Error2 = "Cannot be left blank!";
if ($error == $Error0){
_fail($Error0);
}
else if ($error == $Error1){
_fail($Error1);
}
else if ($error == $Error2){
_fail($Error2);
}
else _log("passed"); //optional
};

Answers
Thank you Pratyush