3

I have situation where name and value pair are dynamic, I did two correlations for name and Value separately. I have used foreach controller and gave input-value as reference name of "Value" regularexpression. which is executing the loop correctly as the match number of Value. enter image description hereenter image description hereenter image description hereenter image description here ForEach controller input index is "Cor_OutputValue" and output index is "Cor_OutputValue1".

Problem is how do i change the "Name" for each request .

Regards, Sai

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Please share your test plan and problem as a snapshot,if possible, to get a quick response. – sunny_teo Jun 11 '18 at 11:44
  • You need to use jmeter 4 and use in index variable the for each controller **name**, if it's named `FEC` Use `${__jm__FEC__idx}` – Ori Marko Jun 11 '18 at 15:21

1 Answers1

3

ForEach Controller save index of loop in a special variable you can use:

JMeter will expose the looping index as a variable named jm__idx. So for example, if your Loop Controller is named FEC, then you can access the looping index through ${__jm__FEC__idx}. Index starts at 0

So in case of your controller name is ForEach Controller to get corresponding value of Value variable use __V function:

${__V(Value_${__jm__ForEach Controller__idx})}

If your values start with index 1 you can increment different variable,as idx inside JSR223 PreProcessor:

vars.put("idx", String.valueOf(Integer.parseInt(vars.get("__jm__ForEach Controller__idx"))+1));

And use it later

${__V(Value_${idx})}
Ori Marko
  • 56,308
  • 23
  • 131
  • 233