Recognizing text fields according to their label value

Posted by Pierpaolo Bagnasco on Programmers See other posts from Programmers or by Pierpaolo Bagnasco
Published on 2012-06-19T15:16:38Z Indexed on 2012/06/19 15:23 UTC
Read the original article Hit count: 181

Filed under:
|

I have an application who has text fields (not select, not checkbox or other types) where an user can enter some value, like this:

*ISBN* and *E-Mail* are the label of each input

ISBN and E-Mail are the label of each input.

Now I have to automatically test these inputs according to their label. The question is: how to recognize that, for example, the first input requires an ISBN code? I programmed something like this:

  1. turn the label value to lowercase
  2. check if the label value contains isbn
  3. if so set the field value to a random ISBN code (i.e.: 1234567890), else set it to a random value (default)

For the email field:

  1. turn the label value to lowercase
  2. check if the label value contains e-mail or email or mail
  3. if so set the field value to a random email (i.e.: [email protected]), else set it to a random value (default)

And so on for each text field I encounter.

Is that reliable? How can I improve the "recognizing part"? I know only the label value and the field value (what is already written in the field by default) for each text input.

© Programmers or respective owner

Related posts about testing

Related posts about auto-completion