Reputation: 1149
For the purpose of my test, Based on the JDBC query id's i need to pass to another query, located under ForEach Controller.
url id https://pay1.com/ 1 https://pay3.com/ 3 https://pay8.com/ 8
Based on the ID returned, i need to pass to another query:
select *
FROM transaction
WHERE id = '${id_1}'
If i try like: ${id_1}
or ${id_3}
is working fine.
But, how can i pass dynamically to the next query, without hard coding the index?
Upvotes: 1
Views: 356
Reputation: 168072
ForEach Controller has pre-defined variable exposing the current iteration, as per documentation:
JMeter will expose the looping index as a variable named
__jm__<Name of your element>__idx
. So for example, if your Loop Controller is namedFEC
, then you can access the looping index through${__jm__FEC__idx}
. Index starts at 0
So
ForEach Controller
you can access its current loop as ${__jm__ForEach Controller__idx}
id_
prefixPutting everything together, the code you're looking for would be something like:
${__V(id_${__intSum(${__jm__ForEach Controller__idx},1,)},)}
Demo:
More information: Here’s What to Do to Combine Multiple JMeter Variables
Upvotes: 2