0

I have a Regex Extractor that retrieves following values,

enter image description here

With this, i'm trying to retrieve all such values, orderId_1_g1=SGSM10820, orderId_2_g1=SGSM10821, orderId_3_g1=SGSM10822, and pass them in a HTTP Request that follows as a parameter.

For this, I've put them in a Loop Controller and a Counter. Now, when using ${orderId_${counter}_g1} to get the value; I don't actually receive the value instead get the variable ${orderId_${counter}_g1} as it is.

NOTE: I'm trying to use a counter to form name of another variable. Is it possible or there's some other efficient way to acheive this?

3 Answers 3

1

You cannot concatenate JMeter Variables this way, in order to evaluate nested JMeter Variables you need to use __V() function like:

${__V(orderId_${counter}_g1)}

More information: Here’s What to Do to Combine Multiple JMeter Variables

0

I think what you're after is an array to store these values in:

e.g.

String[] orderId= new String[100];

Then you can either manually set them all

orderId[1]="SGSM10820";
orderId[2]="SGSM10820";
// and so on

Or stick it all in a loop to do a common thing for each entry

for (int n = 0; n < orderId.length; n++) {
    // do something for all entries in array
    //orderId[n] is currently selected

}

0

I've got the solution after tinkering with the controllers for a while.

Instead of using a Loop Controller we can use ForEach Controller and not worry about the complex expression that the RegEx Extractor returns as the latter controller handle that wisely. Use the value in the output variable set into the loop controller to get the desired value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.