Monday, July 11, 2011

Looping through all output of a RegExp extractor (without the for each controller)

I forget why the user couldnt use a For Each controller , but heres how to loop through the result of a Regex Post Processor that returns multiple values

++Regex Extractor (variableName = links)
+WhileController(${__javaScript(${C} < ${links_matchNr})})
++HTTPSampler use ${__V(links_${C})} to access the current result
++Counter (start=1,increment=1,maximum=${links_matchNr},referenceName=C)


Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

I am a beginner, this is the exactly the issue I am trying to deal with. I used regX to parse my response array where ids_matchNr = 63. I followed your instruction to loop the next http request sample, using the previously parsed ids from regX but the loop does not repeat. Can you please help me? Thank you

Deepak Shetty said...

why not use a foreach controller?

In most cases check jmeter.log for errors and add some debug samplers and view results tree listener so you can check the values of the variables to diagnose the issue

Anonymous said...

Sorry I am new to JMeter. Can you please tell me how to increment the foreachloop count to use the multiple variables extracted by the regX. Thank you

Deepak Shetty said...

The for each controller doesnt need you to have any counter
Say if your regex output variable is extractedVariable (which has many values) Then just Use
ForEachController and in input variable prefix use extractedVariable (same name as you specified in the regex extractor)
and in output variable name use any value (you will refer to this value)

+Regex (var = extractedVaribale)
ForEach (input=extractedVariable, output=currentValue)
+HTTPSampler2 (use ${currentValue})

This will execute HTTPSampler2 as many times as you have the value and ${currentValue} will be the value inside the loop (value1,value2,value3 etc)

Use Debug Sampler + View Results Tree if something is not working to diagnose issue
and refer to

Anonymous said...

works like a charm! thank you!