How to handle html5 constraint validation pop-up using Selenium?

前端 未结 3 759
长发绾君心
长发绾君心 2021-01-23 02:44

The picture says it all. After click on \"LOG IN\" button, \"Please fill out this field.\" pop-up message appears. It looks like some javascript thing. I want to get te

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 03:19

    I have also encountered this type of page previously and i had a discussion with the UI developers at that time. The errors which are displayed on the UI is the native browser support and every browser would by default show this error message if the field is left blank.

    This was introduced in HTML5 and if there is an attribute required="required" in the html structure of the element then the browser will by default show the error message which you are getting. So if you also check your element, required="required" is present in your element's html as well.

    Generally, websites do not use this feature because they use their customised error messages on the page but in your case its being used. Therefore, it is not possible to detect this error message using selenium as the error message is not present on the UI or anywhere in the code. So, either you ask your developers to change the implementation or you need to skip these validations from your test suite.

提交回复
热议问题