Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jmeter - combine two variables into one

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.

like image 604
user2880391 Avatar asked Feb 16 '26 22:02

user2880391


1 Answers

The correct syntax would be:

${__V(SB_names_${counter})}

For example, if one has variables A1,A2 and N=1:

${A1} - works OK

${A${N}} - does not work (nested variable reference)

${__V(A${N})} - works OK. A${N} becomes A1, and the __V function returns the value of A1

References:

  • __V() function manual
  • How to Use JMeter Functions - series of articles with extended information on using JMeter functions
like image 187
Dmitri T Avatar answered Feb 18 '26 20:02

Dmitri T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!