Randomly selecting object from a web page in TruClient- HPE Loadrunner

1.2k Views Asked by At

I am working Loadrunner 12.55, and Using TrueClient Protocol to design script for my application.

I have been blocked in an issue, where for each iteration the script should click on random object in the list . Not able to achieve this through normal Parameterization provided by TrueClient.(It doesn't allow me to parameterize Action itself).

Below is the step configuration i tried but didn't work:

Click on PerfTest3

Roles: "javascript_link, focusable, element"
Name: PerfTest3
ID Method: JavaScript
JavaScript =

var linkList = document.getElementsByTagName("a");
random(linkList);

Logic to randomly click objects on the page needs to be written in javascript? Please assist me to solve this issue. PFB screenshot for further understanding the problem. RHS-WEBPage, LHS-StepConfig

Thanks in advance

1

There are 1 best solutions below

1
On

As far as I see your solution to use JavaScript identification and to use the random method that is defined inside the JavaScript identification context is a good one. W hen trying it myself it worked with your code as well but maybe in your case, this is a more complicated DOM hierarchy and in that case, you might want to use the evalXPath method instead of the getElementsByTagName method and change the simple “//a” to something more custom for your application:

var linkList = evalXPath("//a");

random(linkList);

you can also try to use Descriptors and change the identification to this: enter image description here