Home
Filter individual strings from a long string of text PDF Print E-mail
Written by Mark Sibley   
Monday, 16 November 2009 13:58

Another C/LoadRunner function brought to you by Mark Sibley.

I wrote this function specifically to address an unusual issue. I needed to capture a linked set of five pieces of data but was unable to use the standard web_reg_save_param function because the individual boundaries were not specific enough. I was however able to capture all five pieces of data as one long string of text.

This function is designed to take a long string of text and then filter out the data you want based on delimiters you supply. It saves each piece of data as a sequentially numbered parameter using a prefix you supply each time you call the function.

You can download a working example of this function here. In the example you'll see how it turns a string like ('Mark Sibley','01234567','01-23-45','01/12/2009','AA1 1AA') into seven sequentially numbered parameters named {SecondSet_1} through to {SecondSet_7}.

I often call this function within a WHILE loop where I compare one of the filtered parameters against a known value until I find the one that matches a known value and then save the related values as separate parameters.

For example lets assume you're writing a LoadRunner script that simulates usage of online banking. You may only be able to complete the process you've recorded if you access the current account. What you'll probably find is that some customers have more than one type account and they're not always listed in a predictable order. This function, combined with the WHILE statement, allows you to capture the details of each account on screen and compare the known account number to the one you've filtered. When you identify the row of data that has the account information you need this function then saves the associated details like the sort code or account name etc into the sequentially numbered parameter names.

 

Last Updated on Monday, 16 November 2009 14:09
 
Copyright © 2010 Richard Bishop. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.