Jmeter - combine two variables into one

时间:2016-04-04 05:58:29

标签: json foreach jmeter

I have extract Json element in previous step (which created an array) and I want to access specific element inside using counter variable (inside foreach). this is the element that holds the array:

SB_names

and inside the 'Foreach' I have created a counter with variable - 'counter'. now, in the name of the http request I'm trying to access each element of the array in each iteration. this works for example:

${__V(${SB_names_1})}

but I want to do something like this (which currently is not working):

${__V(${SB_names_${counter}})} 

thanks.

1 个答案:

答案 0 :(得分:4)

正确的语法是:

${__V(SB_names_${counter})}
  

例如,如果有变量A1,A2和N = 1:

     

$ {A1} - 工作正常

     

$ {A $ {N}} - 无效(嵌套变量引用)

     

$ {__ V(A $ {N})} - 工作正常。 $ {N}变为A1,__ V函数返回A1

的值

参考文献: