Please see my below code:
My if
part of code is running successfully but my else
part is not working.
The code gets skipped and is showing failure.
if (driver.findElement(By.id("error_explanation")).isDisplayed() == true) {
driver.findElement(By.id("user_email")).clear();
driver.findElement(By.id("user_email")).sendKeys("soumya50@toobler.com");
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.findElement(By.id("user_password")).sendKeys("password");
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.findElement(By.id("user_current_password")).sendKeys("password");
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.findElement(By.name("commit")).click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.linkText("LOGOUT")).click();
} else
{
driver.findElement(By.linkText("REQUEST A PERMIT")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
Getting error as below:-
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"error_explanation"}