1

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

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
blue
  • 217
  • 6
  • 18

1 Answers1

2

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

Ori Marko
  • 56,308
  • 23
  • 131
  • 233