I am running a simple test in Selenium Java to test login however my if statement keeps jumping straight to the else saying it Login has passed even though I know it has failed.
// if error message test fails
if (driver.getPageSource().contains("User not found")) {
System.out.println("Login Failed - incorrect username ");
Thread.sleep(1000);
driver.quit();
} else if (driver.getPageSource().contains("Incorrect Username or Password!")) {
System.out.println("Login Failed - incorrect username or password");
Thread.sleep(1000);
driver.quit();
} else if (driver.getPageSource().contains("Account is locked")) {
System.out.println("Login Failed - Account locked");
Thread.sleep(1000);
driver.quit();}
} else {
System.out.println("Login Passed");
// Open Nav Bar
driver.findElement(By.xpath("//*[@id=\"root\"]/div/div/div[1]/div[1]/button")).click();
Thread.sleep(1000);
// log out
driver.findElement(By.xpath("//*[contains(text(),'Log out')]")).click();
driver.quit();
}
What am I missing?
Aucun commentaire:
Enregistrer un commentaire