Please see this website.
After click log in i have this User credentials form and after try to login with missing Email Address
or Password
i got this message:
So i try to find this element by print all the page HTML
(driver.getPageSource()
) but this text is missing.
Any idea how to verify that i have this error message
?
Attribute
validationMessage
will return the message, that will be showing if validation fails:If element has
required
attribute, browser will show the message after submitting the form:You can check whether entered value is valid:
Not: message text and validation is customizable. If you want to test customized validation and message.
Here test code for custom validation(Java, TestNG):
The validation messages are not the part of your DOM. They are generated because your input fileds have
required
attribute. If you see the HTML of your fields -You can see it has required attribute turned on. Check this out. You can verify that your fields have this required attribute or not, like this-
There is no need to care about whether the message appears or not because that will handled by the browser.