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.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:turn the label value to lowercasecheck if the label value contains isbnif 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:turn the label value to lowercasecheck if the label value contains e-mail or email or mailif so set the field value to a random email (i.e.: abcd@abcd.com), 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.
Recognizing text fields according to their label value
java;testing;android;auto completion
As for the correctness of your feature, it simply is not. In fact, it cannot be.Trivial counter-example: Someone creates the label Do not enter E-mail or ISBN here, but your name:The problem is that you should not have to guess which textfield is for which purpose, but the text-field itself should contain this information for various reasons.For example, if you have a textfield for ISBNs, you do not want a keypress for a non-digit-character to even appear (with the possible exception of the - and X characters maybe).The main problem is how to add this semantic information to the text-fields such that you can access it in the test framework. This of course depends on the specific implementation tools being used. Examples include:HTML: assign a class/id/name-attribute to the input tag (look f.ex. at the source code of the google login page. This is used as the basis of how your browser knows in which text field it should auto-complete your e-mail address)GUI API: If you create an instance of some TextField widget, you can create subclasses for the different semantical purposes, like an EMailTextField, and instantiate that. By reflecting on the dynamic type of the textfields, your tests can then determine what kind of textfield it is, and additionally, the implementation can easily realize semantic-dependant behaviors (like disallowing certain characters to be entered, etc.)