I was at a conference some months ago when Danny Faught showed me a Perl package for manipulating the Windows clipboard. I turned it into a little tool for helping me test text fields.
It’s called PerlClip. Feel free to download it. You don’t need Perl to run it.
One of the things PerlClip does is allow you to produce what I call “counterstrings”. A counterstring is a graduated string of arbitrary length. No matter where you are in the string, you always know the character position. This comes in handy when you are pasting huge strings into fields and they get truncated at a certain point. You want to know how many characters that is.
Here is a 35 character counterstring:
2*4*6*8*11*14*17*20*23*26*29*32*35*
Each asterisk in the string occurs at a position specified by the immediately preceding number. Thus, the asterisk following the 29 is the 29th character in that string. So, you can chop the end of the string anywhere, and you know exactly where it was cut. Without having to count, you know that the string “2*4*6*8*11*14*17*2” has exactly 18 characters in it. This saves some effort when you’re dealing with a half million characters. I pasted a 4000 character counterstring into the address field of Explorer and it was truncated at “2045*20”, meaning that 2047 characters were pasted.
I realize this is may not be a very interesting sort of testing, except perhaps for security purposes or when you’re first getting to know the app. But security is an increasingly important issue in our field, and sometimes when no one tells you the limits and dynamics of text fields, this can come in handy.
Michael Holmes says
I’ve used this tool and found it very helpful in things like field validation as suggested in the field – Requirement states that field will accept a maximum input of 200 characters. Great create a string, put it in your automation library, have your automation tool call the string to test the value. Requirement changed? Create a new string with same name!
Also have used it for creating large quantities of data for insertion into database applications under test.
Testing indexing in databases through creating huge strings and using find and replace to change or strip out the asterisks.
Though for both these cases I have also enjoyed using texts from the Project Gutenberg library – (http://www.gutenberg.org/wiki/Main_Page) I mean Ipsum Lorum does tend to get boring after a while.
José Alejandro Betancur says
james,
is there a way to tell perlclip to create the $allchars backwards?
I figure out that the combination “&#” breaks the application when is used.. and some times some points of the $allchars text backwards also crash apps.
[James’ Reply: There’s no way to do that yet. But it’s easy to tweak the code to make that happen.]Â
Dan Meservy says
I’ve already shared this with a couple of my testing colleagues. Though it’s simple, it’s powerful. Before, we’d hold a button for a long time in a field, then copy to the point of truncation and paste the text in word and do a character count. Cave-man like, I know! Thank you for the tool! It’s in my library now.
Gleb Shevchuk says
A useful testing tool.
Thanks.
Jin says
Typo,possibly? 17*2 ??
[James’ Reply: I know it looks like one, but it isn’t. The full string was 2*4*6*8*11*14*17*20*23*26*29*32*. When that is truncated to 18 characters it will end in “”2″”]
Jin Kwon says
A way in Java to generate counterstrings.
https://gist.github.com/jinahya/c278ccad5df4b2e754667f29751a9e3a
Vincentd123 says
javascript code which you can copy paste into dev tools console
“` javascript
let str = “”
while (str.length < 1000){ str = `${str}${str.length + 1 + str.length.toString().length}*`}
console.log(str)
“`
ps. testing if comments support markdown 😉