Ask a Question

Keyword test validate characters in input field.

SOLVED
JBSoccerbrit
Contributor

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. The closest I have found is Property checkpoint doesn't appear to offer counting characters of the string itself.

Thanks,

2 ACCEPTED SOLUTIONS

Accepted Solutions
HKosova
Moderator

Re: Keyword test validate characters in input field.

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.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

HKosova
Moderator

Re: Keyword test validate characters in input field.

Make sure to scroll to the end of the list:

 

matches.png


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

5 REPLIES 5
Kamal_chennai
Contributor

Re: Keyword test validate characters in input field.

Hi,

 

You can use "aqString.GetLength" Instead of Property checkpoint

 

1. Get the String From Object Property and Store into the "SetVariable" E.g., (String_Value = "123456789")

2. Then get the Length using aqString.GetLength(String_Value)

It may helpful 🙂

 

Thanks, Kamal

HKosova
Moderator

Re: Keyword test validate characters in input field.

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.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

JBSoccerbrit
Contributor

Re: Keyword test validate characters in input field.

For the property checkpoint option I don't see "matches" as a selection?

Equals
Does not equal
Greater than
Less than
Greater than or equal to
Less than or equal to
Contains
Does not contain

These are my only options?

HKosova
Moderator

Re: Keyword test validate characters in input field.

Make sure to scroll to the end of the list:

 

matches.png


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

JBSoccerbrit
Contributor

Re: Keyword test validate characters in input field.

Thank you, gotta keep on scrolling... derp derp.


cancel
Showing results for 
Search instead for 
Did you mean: