My situation
- Going to a specific page
- Should I click the element that is displayed
- If the element is not displayed, just ignore it
My function
exports.checkButton = function (driver) {
driver.findElement(By.css(".btn.btn-danger.pull-right.remove-promotion")).then(function(button){
if (button.isDisplayed()) {
console.log("The element is displayed");
} else {
console.log("The element is not displayed");
}
});
My issue
When the element is not displayed, the message
console.log("The element is not displayed");
is not showing up and I'm getting an error:
Uncaught NoSuchElementError: no such element: Unable to locate the element: {"method":"css selector","selector":".btn.btn-danger.pull-right.remove-promotion"}