blue
blue

Reputation: 217

Get value for dynamic vars.put

If I set the put key value to the dynamic i value in the graph (this is a requirement),

When I get vars.get("i"), I can only get the value aaa2 when i=2

I want to get all the values(aaa1 and aaa2), what should I do? enter image description here

enter image description here

enter image description here

Upvotes: 1

Views: 10635

Answers (1)

Ori Marko
Ori Marko

Reputation: 58882

To view multiple values you need to save multiple variables by changing your vars.put line to:

vars.put("i" + i, a);

and then get it using ${i[number]} as:

${i0} ${i1} ${i2}

Another option is to concatenate values to variable ${i] similar to

vars.put("i" , (vars.get("i") == null ? "" : vars.get("i")) + a);

Also change your Beanshell sampler to JSR223 Sampler according to JMeter Best Practices

we advise switching from BeanShell to JSR223 Test Elements

Upvotes: 2

Related Questions