SilkTest Automation | |
Finding Maximum Text Field SizeOur application (and presumably yours too) has the occasional text field. Every text field has a maximum length defined in the specification (or it should). Automation makes it easy to verify these maximum lengths. The first thing I did was to define a routine to test maximum text field length. I pass that routine the TextField in question, plus the expected length (as per the specification). If the length matches the expected length, no messages are posted. However, if they do not match, an error is logged, indicating the actual and expected lengths. The first way I've found to determine the actual length is by a brute force approach. I wrote characters to the field (using TypeKeys), then read the field back to see how long it is. I do make sure I set the Agent's keyboard delay to zero first, and restore it to its original value when I'm done. This allows me to stuff in those keystrokes as fast as possible. The sad thing with this approach is that it's quite slow for really large text fields. Most of our fields are under 64 characters long, and those go pretty fast. However, most text fields that do not have a maximum length set will accept 16,384 characters, and that generally takes more than an hour. With a little creativity, I could make some changes that should speed it up. For instance, if my expected maximum were 80 characters, I could verify that 80 works, and that 81 fails (i.e. returns 80). This would let me try just two tests - the expected length, and that length plus one. This would give me a quick pass/fail response. If it does fail, however, it would be nice to know what the maximum is set to, so I can pass that on to the developers when I write up a QA ticket. There are several methods to find long lengths. Right now, I add on one character at a time. It would be easy enough, however, to add on 100 at a time (or any other number you like), then keep adding until it fails. At that point, subtract your increment and starting adding one at a time (or ten, or whatever). This method should cut down the number of comparisons by an order of magnitude or more. The simplest method would be to stuff a string of 16,384 characters in with SetText, read it back with GetText, and get the length of the return string - this should be the maximum length. This would cut the number of SetText/GetText calls to exactly one. Now, this routine takes the same amount of time no matter how long the maximum string is. Followup: I now have a two-part test, and this seems to work best. First, I check the anticipated length plus one - if the anticipated length equals the real length, then we're done with one short SetText/GetText call pair. If that fails, however, I attempt to stuff in all 16383 characters (the maximum string length in SilkTest). This takes longer than the first test but is only needed when the string is not the correct length. Now, the result is this test takes less than a minute for the longest strings, and only a few seconds if it actually matches. |
About MeMy Profile Archives Friends My Photo Album LinksCategoriesLocalizationObscure Stuff Configuration Management Recent EntriesFinding Maximum Text Field SizeBuilds - How Often? Sort Order Localization Testing Friends |