Procedure to select Random Value Using Truclient Protocol in LoadRunner?
1. How to select a random value from dropdown list
using TruClient protocol in LoadRunner?
Selecting Random value from Dropdown List
To select any random value from the dropdown list, follow the below mentioned steps:
1. Record the script in Develop Mode.
2. Go to the dropdown step
3. Expand Arguments
4. Clear the Text
5. Enter Ordinal value as 0.
6. Save the script.
Selecting Random Radio Button value – How to select
random radio buttons using TruClient protocol in
LoadRunner?
To select a random value from the dropdown list follow the below mentioned step:
1. Record the script in Develop Mode.
2. 2. Go to the radio button step.
3. Make sure that Step Action is Click.
4. Expand Object option.
5. Give any name in Name field.
6. The JavaScript code that will be written evaluate the XPath. First we have to find the
XPath expression related to the radio button.To know the XPath of the radio button, Select
the ID Method as XPath à Click on the XPath Expression à Copy the expression in Notepad
3. Record the step of selecting different radio button option and copy the expression for each
radio button selection. Now find the difference among the expression.
E.g. In the above script, the user can select any one of seat preference option [Aisle,
Window or None] by clicking on the radio button.
Minimum no of seat preference option that needs to be selected = 1 [Min]
Maximum no of option available for selection = 3 [Max]
The Xpath expression for Aisle, Window and None radio button selection are as follows:
As you can see in the above XPath expressions, the dimension of the array label[] is
changing, that means that the selection of the radio button depends on the dimension value
of array label[].
4. 7. Select ID Method as JavaScript.
8. Write the following code in JavaScript field by opening the Edit in JavaScript
Editor button which will appear at the end of the field.
//Declare the variable to hold the random value
var options;
//Assign a random value using the following operation
//(Math.floor(Math.random() * Max – Min + 1) + Min )
options = (Math.floor(Math.random() * 3)+ 1);
//Replace the value of the array on which the selection of radio button is dependent
evalXPath(“/html/body/blockquote/form/table/tbody/tr[5]/td[1]/label[“+options.valueOf()+”]/
input”);
9. Save the script.