Here I wanted to run this method properly when boolean values are false, but when running this method it always failed the test case saying "no such element: Unable to locate element".How can I handle the boolean = false here?
public void loginToStrata(String email,String psw) throws InterruptedException {
enterEmail(email);
enterPassword(psw);
clickLogin();
Thread.sleep(1000);
boolean emailErrorPresence=driver.findElement(emailError).isDisplayed();
boolean pswErrorPresence=driver.findElement(pswError).isDisplayed();
if(emailErrorPresence==true){
String emailErrorMessage = driver.findElement(emailError).getText();
System.out.println(emailErrorMessage);
}else if (pswErrorPresence==true) {
String pswErrorMessage = driver.findElement(pswError).getText();
System.out.println(pswErrorMessage);
}else if(emailErrorPresence==false && pswErrorPresence==false) {
boolean sysHeadingPresence=driver.findElement(portalHeading).isDisplayed();
System.out.println(sysHeadingPresence);
String heading = driver.findElement(portalHeading).getText();
System.out.println(heading);
}
}