when relevant content is
added and updated.
VBScript, the internal language of HP QuickTest Pro, is rather handy for manipulating text strings. This is especially useful when you are trying to verify a test step where only part of your actual data will match your expected data, or vice versa.
Here is a simple function which removes the specified leading characters from a text string:
Let’s say your application returns some data that always begins with “ABC” and ends in some varying values, like “ABC0089”, “ABC00390”, etc., while your expected values are extracted from a table that does not contain the constant leading value of “ABC”. You could do a quick comparison using the above function:
” If removePrefix(ApplicationDataString,”ABC”)= ExpectedString Then…”, and so on.
Here’s a similar function that can remove the trailing characters from a string:
The idea is very similar to the first function, but the target characters now appear at the end of the input string rather than at the beginning.
Finally, here is a function that can pad a string with any characters you specify, either on the right or the left side of the original text:
This technique can be used to pad number fields with zeroes at either end of the original string. For example, if you have a numeric value “12345” which must be eight characters long padded with leading zeroes, the function makes the conversion a simple call:
ApplicationData = padString(ApplicationData,8,”0″,”L”)
See, pretty easy, huh? Be creative, code wisely, and AUTOMATE!