Jmeter Property with array of values

7.8k views Asked by At

Requirement: Need to store 50+ values to a Jmeter property and use with idx

enter image description here

In the case of normal variable we can use Country_1 or Country_2.

Do we have any function to set an array of values to jmeter Property and how to get value using index?

Note: In this case,value has to be used in different thread group.

1

There are 1 answers

0
Dmitri T On BEST ANSWER
  1. Your ArrayList initialization is not correct, you should be doing something like:

    List myList = Arrays.asList('India', 'USA', 'UK')
    
  2. There is no putObject method in props shorthand (which is basically an instance of java.util.Properties class so you will need to amend your code like:

    props.put('Middle', myList)
    
  3. Once done you will be able to access individual list members using __groovy() function like:

    • ${__groovy(props.get('Middle').get(0),)} - for first member
    • ${__groovy(props.get('Middle').get(1),)} - for second member
    • ${__groovy(props.get('Middle').get(2),)} - for third member
    • etc.

Demo:

JMeter Access Array Members

See Apache Groovy - Why and How You Should Use It article for more details on using Groovy scripting in JMeter tests.