Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, windows and java based applications. Get your 30 day free trial.
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
How to know whether or not a element exist on page
ziscloud
Members
Hi All,
I try to use this code to verify whether a element exist on the page:
if (_condition(_link($label) != null)) {
_click(_radio(0, _near(_link($label))));
} else {
_click(_cell(0, _near(_cell($label))));
}
}
Some times it is work fine, but some times even there is a link element, it also clicks the cell element!
I have used the sahi controller to verity _assertExists(_link("xxxx")), it return true, but in the script
_condition(_link($label) != null)
return false and click the cell element.
is it a bug of sahi, please verify!
I try to use this code to verify whether a element exist on the page:
if (_condition(_link($label) != null)) {
_click(_radio(0, _near(_link($label))));
} else {
_click(_cell(0, _near(_cell($label))));
}
}
Some times it is work fine, but some times even there is a link element, it also clicks the cell element!
I have used the sahi controller to verity _assertExists(_link("xxxx")), it return true, but in the script
_condition(_link($label) != null)
return false and click the cell element.
is it a bug of sahi, please verify!
Comments
are you mean the code should like this:
_assertExists(_link($label)); or _wait(10000);
if (_condition(_link($label) != null)) {
_click(_radio(0, _near(_link($label))));
} else {
_click(_cell(0, _near(_cell($label))));
}
}
??
This will wait till given amout of time or provided link was found. whichever occurs first. Assert is much better in your case.
if(_assertExists(_link("clickme"))){
_alert("it exists on the page");
}
if(_condition(_assertExists(_link("clickme")))){
_alert("it exists on the page");
}
if(_condition(_link("clickme"))){
_alert("it exists on the page");
}