I want to check if an element is visible and if it's not, I want my test to continue with something else.
The problem is that if element is not visible, nothing seems to be working... I've already tried isDisplayed()
, isPresent()
, invisibilityOf()
... but test fails if element is not visible.
Eg.
element(myElement).isDisplayed().then(function(result) {
if (result) {
//do something
}
else {
//do something else
}
}
This works just fine if myElement is present. But if not, test fails with error: No element found using locator: By.cssSelector(myCss)
. So somehow it doesn't resolve the promise returned by isDisplayed()
, so it never goes to else section.
What can I do to keep my test running if element is not displayed?