I have been trying to use the code snippet below to check if the element I'm looking for exists, however all I get is "Failed: No element found using locator: By(css selector, .icon-cancel)". What I want the program to do is to execute b()
element(by.css('.icon-cancel')).isDisplayed().then(function(result) {
if ( result ) {
a();
} else {
b();
}
});
isDisplayed()
would fail if an element does not actually exist in the DOM tree. You need the isPresent()
method instead:
$('.icon-cancel').isPresent().then(function(result) {
if ( result ) {
a();
} else {
b();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With