Highlighted
Captain
Captain
861 views

TruClient Web - How to select a random action?

Within the truclient interface I have a group of actions that are grouped together into a For...Next loop and want to randomly select one of the actions to execute. Is there a way to do this in the native TruClient interface or do I need to switch to a code-based TruClient script?

0 Likes
2 Replies
Highlighted
Fleet Admiral
Fleet Admiral

Hi,

You can add an "If Block" from the Toolbox and surround any step you wish. Write JavaScript code with some randomization logic to ensure the If step condition is true randomly.

Regards,

Shlomi

 

Vice Admiral Vice Admiral
Vice Admiral

I implemented Shlomi's way to select random step. 

1. Drag and drop javascript and add below code.

var i;
i=Math.floor((Math.random() * 3) + 1);

//change the number 3 into number of steps you have in the for loop.

2. In For loop, change the variable from i to j

3. Surround each step inside For Loop by if condition and add the condition for each if step as shown below.

https://cl.ly/q4Un 

 

 


Thank you,
NaveenKumar Namachivayam | www.QAInsights.com
Learn TruWeb - my Udemy Course "Performance Testing using TruWeb" | https://www.udemy.com/performance-testing-using-truweb/?couponCode=YOUTUBE
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.