Skip to main content

Posts

Showing posts from December, 2015

JMeter: getting a value from the randomly selected variable

Assuming we have a CSV Data Source with multiple rows and 10 values in every row. We are parsing and storing the values into a set of variables, named var1,var2,var3,var4,var5,var6,var7,var8,var9,var10 . Now we can use these variables in any step using ${varN} reference. But what if we want to select a variable from this list randomly? So that one iteration would use var3 , and another iteration would use var7 , selected randomly. I have used the following solution: Create additional user defined variable varTmp using "User Defined Variables" config element. Create "Random Variable" config element with variable name rnd , minimum value 1 and maximum value 10. Then use BeanShell PostProcessor that will store the value from randomly selected variable (var1-var10) into varTmp . We need to define two fields in the config element:  Parameters:  ${__V(var${rnd})} Script: vars.put("varTmp", bsh.args[0]); Now we can use ${varTmp} as a reference to the