How to select a random parameter from a captured list using LoadRunner

LoadRunner Screenshot

When performance testing it is important to simulate realistic user journeys through an application. With this in mind it might be necessary to choose options at random from a list. In the example below which was used to performance test a share dealing application it was necessary to simulate the purchase of different shares so that all vUsers aren’t selecting the same share.

The lr_paramarr_random function can be use to simulate users selecting different items from a dropdown list.
First capture the parameter using a web_reg_save_param function, select all ordinal values using ORD=ALL.
LoadRunner Screenshot

In the example above the following values were captured.
Action.c(118): Notify: Saving Parameter “CompanyName_1 = BARCLAYS ORD GBP0.25”
Action.c(118): Notify: Saving Parameter “CompanyName_2 = HBOS ORD GBP0.25”
Action.c(118): Notify: Saving Parameter “CompanyName_3 = LLOYDS TSB GROUP ORD GBP0.25”
Action.c(118): Notify: Saving Parameter “CompanyName_4 = TESCO ORD GBP0.05”
Action.c(118): Notify: Saving Parameter “CompanyName_5 = VODAFONE GROUP ORD USD0.11428571
The lr_save_string function is then used to save one of the “CompanyName” parameters into a new parameter called “RandCo”.

LoadRunner screenshot

e.g.
Action.c(154): Notify: Parameter Substitution: parameter “RandCo” =  “HBOS ORD GBP0.25

Author: Richard Bishop

http://about.me/richard_bishop