How to get HTML5 validation error message text using selenium webdriver

2,943 views
Skip to first unread message

Jayendra B

unread,
Apr 12, 2015, 5:08:05 PM4/12/15
to webd...@googlegroups.com
I wants to read the HTML5 required field error messages using selenium webdriver with java

http://ipic.su/img/img7/fs/kiss_11kb.1428560879.png

I want the text "Please fill in this field" using webdriver


darrell

unread,
Apr 13, 2015, 8:10:25 AM4/13/15
to webd...@googlegroups.com
If the input element has the attribute 'required' then it will display "Please fill in this field.". So all you have to do is find the element, using findElement() then use getAttribute('required'). If getAttribute returns NULL then the attribute does not exist. Otherwise, it should return the String "true".

Subhash Gaddampally

unread,
Apr 16, 2015, 7:45:37 AM4/16/15
to webd...@googlegroups.com
you can use mouse hover to that element with the help of moveToElement method from actions class. and then check error message element is present .and then extract text by getText()

this scenario is like tooltip information on mouse hover.
Reply all
Reply to author
Forward
0 new messages