Let say I have the following snippet of HTML5:
<form method="get" action="logginValidation.php">
<input type="text" required="" name="username">
<button class="btn" type="submit">Se connecter</button>
</form>
Using Selenium, I leave the field empty and press the button.
The form is not validated as I would expect, but how can I verify that this field is invalid and that there’s an associated message with this field.
Now one thing I haven’t investigated is that I’m using Twitter Bootstrap with the JavaScript libraries loaded. I have to double check if those librairies aren’t playing tricks on me and that the validation is really coming from the Firefox browser.
From Selenium documentation:
That mean that the :required, :invalid and :valid are not pseudo element on which you can select of interact with.
I work around this limitation by doing a VerifyNotText for a text that is on the following page. Not ideal, but work.