Forum Discussion

JBSoccerbrit's avatar
JBSoccerbrit
Contributor
9 years ago
Solved

Keyword test validate characters in input field.

Is it possible to validate using keyword tests how long a value is in an input field. For example; Input field 1 contains 123456789, I would like to confirm that the length is 9 characters long...
  • HKosova's avatar
    9 years ago

    To elaborate on Kamal's answer, you can use If..Then and aqString.GetLength to verify the string length, like this:

     

    keyword-checkpoint-for-string-length.png

     

     

    Another option is to use a property checkpoint with a regular expression for exact string length. Use the Matches condition, and this regular expression with the same number of dots as the expected string length (9 in your example):

     

    ^.........$

    Here, a dot (.) matches any character. ^ and $ mean the beginning and end of the string, to match exact string length (without using ^ and $ you will also get a match for strings of 10 and more characters.)

    The drawback of this method is that the checkpoint results do not include the string length as a number, so you won't see the number 9 in the log.

  • HKosova's avatar
    HKosova
    9 years ago

    Make sure to scroll to the end of the list:

     

    matches.png