RE: HTML 5 provide “required” attribute. For Email field, It give different message based on email entered. I want to check these message using Selenium webdriver, Please Help.
This is a good question, however there is no way right now that you can read HTML 5 error messages. The reason is that the error message is not part of the DOM and is also generated by the browser. Every browser will have different implementations for it.
All you can validate is that whether the element is in error state or not. You can find the current element which is in error state by using following command
WebElement invalidInput = driver.findElement(By.cssSelector(“input:invalid”));
Just verifying that this is indeed the element that should have thrown error should be enough to tests.
Error message that you get is from browser and you cant do much about what error message browser chooses to display.