My scenario
- access a specific page
- While showing the element, should I click it
- If don't show this element, ignore
My code
exports.checkButton = function (driver) {
driver.findElement(By.css(".btn.btn-danger.pull-right.remove-promotion")).then(function(button){
if (button.isDisplayed()) {
console.log("Displaying");
} else {
console.log("not displayed");
}
});
My problem
If the element is not displayed, it does not show the message console.log("not displayed");
and I'm getting error:
Uncaught NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":".btn.btn-danger.pull-right.remove-promotion"}