driver.get(“http://www.gmail.com”);
if(driver.findElement(By.className(“runner-canvas”)).isDisplayed()) {
System.out.println(“Internet is not working”);
// throw new Exception(“Internet is not working”);
}
System.out.println(“Enter Email-Id”);
WebElement Email = driver.findElement(By.name(“Email”));
isDisplayed never returns false, it rather throws execution better use Exists()
1 Like
Actually, isDisplayed will not throw an exception. findElement()
will throw the exception if no element is found. See Javadoc for WebElement and WebDriver
1 Like