I'm running a Thread Group with the following property values:
Number of threads: 200 Ramp-up Time (sec): 20 Loop-count: 2
I also have user defined variables set for the HTTP Requests. However, when the second iteration is reached, I need the user defined variable's value to also change.
Put the following code into PreProcessor's "Script" area:
if (vars.getIteration() == 2) {
vars.put("myVar", "newValue");
}
Replace myVar
with your variable name and newValue
with variable value for the second loop.
vars
is a shorthand for JMeterVariables class instance and getIteration() method returns current loop's number.
If you want to dive deaper into Beanshell in particular and extending JMeter test via scripting in general I would recommend to get familiarized with How to use BeanShell: JMeter's favorite built-in component guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With