How to use Array list in Beanshell Sampler-Jmeter?
Just like in Java, i.e. the following code:
ArrayList myList = new ArrayList();
myList.add("something");
myList.add("something else");
for (int i = 0; i < myList.size(); i++) {
log.info(myList.get(i));
}
Will print myList
contents to jmeter.log file:
Remember that Beanshell doesn't support Generics so avoid using diamond operators elsewise you'll get errors. If there is no particular reason for sticking to Beanshell I would suggest considering switching to JSR223 Test Elements and Groovy language - see Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for explanation, benchmarks and scripting best practices.
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