Using selenium webdriver to test if the button is not visible the boolean is always returning true.
using below code and returns TRUE,in web page I can see the xpath for Add button. Button is not visible.
boolean present;
try {
//driver.findElement(By.xpath("//button[@id='add']"));
driver.findElement(By.xpath("//button[@id='add']")).isDisplayed();
present = true;
System.out.println("Add button is present");
} catch (NoSuchElementException e) {
present = false;
System.out.println("Add button is not present:" +e.getMessage());
}
xpath: addButtonxpath