Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing two variables in a ForEach controller in jmeter

Tags:

jmeter

I am running a ForEach controller in which I want the controller to run the service underneath it for changes in sets of latitudes and longitudes. example-

Input variable prefix: latitude

Output variable name: Latitude

I want to run the controller for changes in both "latitude" and "longitude". I tried doing this-

Input variable prefix:latitude, longitude

but it does not work. Is there any other way to pass two variables in ForEach controller?

like image 323
TFK Avatar asked Jul 19 '16 16:07

TFK


Video Answer


1 Answers

Unfortunately you cannot do it using ForEach Controller, but you can work it around using __V() and __counter() function combination.

For example you have 4 JMeter Variables:

latitude_1=40.7128° N
longitude_1=74.0059° W
latitude_2=32.0853° N
longitude_2=34.7818° E

And you want to iterate them both using ForEach Controller. In that case the relevant configuration would be:

  • Input variable prefix: latitude
  • Output variable name: anything meaningful, i.e. current_latitude

You can refer matching longitude value using the following expression:

${__V(longitude_${__counter(,)})}

Demo:

Combine Variables

See Here’s What to Do to Combine Multiple JMeter Variables for detailed explanation of where did the above expression come from.

like image 73
Dmitri T Avatar answered Sep 21 '22 04:09

Dmitri T