How to check no. of characters accepted by an input field using Selenium WebDriver?



  • I want to check the validation of an input field that what is the number of character it accepts? Suppose an username field is allowed to accept 15 characters then how can I automate this test?



  • It depends on implementation of input field. 1) All major browsers support maxlength attribute. Look at source code of the page and verify if the input field has it. Desciption and example: http://www.w3schools.com/tags/att_input_maxlength.asp 2) Or you can enter very long text in the field and see what happens. To generate very long string you can use this service.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2