Is there a way to select the validation pop-up messages generated by the browser when a user inputs an incorrect format, such as an invalid email address?.
I am writing a test case to verify whether the browser's validation message disappears once the user corrects the email format to the correct one.
// URL to test : https://phptravels.net/login
@Test(priority = 27)
public void verifyErrorMessageDisappearsOnInputChange() throws InterruptedException {
loginPage.enterEmail("wrongphptravelscom");
loginPage.enterPassword("wrongpass");
loginPage.clickLogin();
WebElement emailInput = driver.findElement(By.id("email"));
JavascriptExecutor js = (JavascriptExecutor) driver;
String validationMessage = (String) js.executeScript("return arguments[0].validationMessage;", emailInput);
Assert.assertTrue(validationMessage.length() > 0);
loginPage.enterEmail(validEmail);
loginPage.clickLogin();
Assert.assertTrue(loginPage.getErrorMessage().isEmpty() || loginPage.getErrorMessage().length() == 0);
}