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.
if(_assertExists(_imageSubmitButton("id")) == true) --- not working
OS: Windows XP
Browser: IE8
Sahi Build: V 3.5
I have a common function:
function compare($value1, $value2)
{
if($value1 == $value2)
{
return true;
}
else
{
return false;
}
}
For a particular case, I need to pass the first parameter as _assertExists(_imageSubmitButton("id")) which returns true. So the code will be:
compare(_assertExists(_imageSubmitButton("id")), true);
Now the common function "compare" returns false. However the expected value is true. Any help?
Browser: IE8
Sahi Build: V 3.5
I have a common function:
function compare($value1, $value2)
{
if($value1 == $value2)
{
return true;
}
else
{
return false;
}
}
For a particular case, I need to pass the first parameter as _assertExists(_imageSubmitButton("id")) which returns true. So the code will be:
compare(_assertExists(_imageSubmitButton("id")), true);
Now the common function "compare" returns false. However the expected value is true. Any help?
Comments
please refer to http://sahi.co.in/w/if-condition , you may need a _condition in you if-clause.
Does this help?
Regards
Wormi
BTW isn't your compare function a little bit superfluous? The _assert does everything your compare() does or am I missing something?
I used the below code:
if(_condition(_assertExists(_imageSubmitButton("id")) == true))
{
_alert('pass');
}
else
{
_alert('fail');
}
It gives 'syntax error'. What is the correct syntax here?
The common function is just an example and a simplified one. I am using a different one in my script for some other purpose.
if(_condition(_exists(_imageSubmitButton("id"))))
{
_alert('pass');
}
else
{
_alert('fail');
}
maybe
if(_condition(_exists(_imageSubmitButton("id"))) == true)
is working too
It should be
Check if this solves your issue.
Regards
Sumitra
//case 1
if(_condition(_exists(_imageSubmitButton("gridEventTitle_ctl" + $i_modified + "_EditImage"))==true))
{
// do something
}
else
{
// do something
}
//case 2
if(_condition(_exists(_imageSubmitButton("gridEventTitle_ctl" + $i_modified + "_EditImage"))))
{
// do something
}
else
{
// do something
}
Hi Sumitra,
Both the conditions returned true. Then I entered invalid "id" and expected fail/false. But the code returned pass/true
It should be:
if(_condition(_exists(_imageSubmitButton("id"))))
{
_alert('pass');
}
else
{
_alert('fail');
}
Regards
Sumitra
Function below not works with if condition... made as in your example
in log: Error syntax error
Run script with testrunner.bat
In Sahi Controller _exists(_textbox("Login")) true.
My workaround:
when assertion true -- works perfect: no errors, i see _alert('pass');
when assertion false - have AssertionFailed in log, but if condition works fine: i see _alert('fail');
and all test marked as Failed
Help pls, what condition is correct and will work without errors of assertion?
Try the following script,
This might help you.
Regards,
Theeran.