If-Else condition is not working in Appium(working over Linux OS)

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 :wink:

1 Like