4
votes

I'm creating some tests with JMeter, the situation is very simple, I have a search page with a list of results, and I have to retrieve from this results some values to use in the next request. Those results are around 350, I don't need them all.

I used the RegexExtractor to retrieve those results and it works (I setted it to retrieve just 10 results), but now I don't know how to access the results inside a LoopCounter. The extractor put the results into a variable named Result.

The problem is that I don't know hot to build dinamically the name of a variable. Do I have to use some function like _p()?? I can access the variable just putting the static name Result_0_g1

Inside the LoopCounter I putted also a Counter to store the loop count into the variable index

Thank you

EDIT:

SOLVED I have to write:

${__V(Result_${index}_g1)

4
The solution given here by the OP might work in context but it won't handle no matches on the regex and is generally needlessly complicated in comparison to jmeter's built-in solution.Oliver Lloyd
...You can post your solution as answer and accept it to close the issue - if you believe it's solved.Aliaksandr Belik
mm which are the built-in solution in this case? I've tried with the ForEach controller but it doesn't seem workrascio

4 Answers

5
votes

You have to reference the variable with the function:

${__V(Result_${index}_g1)
1
votes

...Just for collection.
See also this post for another implementation (case without using ForEach Controller):

ThreadGroup 
    HttpSampler 
        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)
0
votes

Use the ForEach Controller - it's specifically designed for this purpose and does exactly what you want.

0
votes

You may use ForEach Controller:

ThreadGroup
    YourSampler
        Regular Expression Extractor (match -1, any template)
    Foreach controller
        Counter(Maximum -> ${Result_matchNr} , Rf Name -> index)
        LinkSamplerUsingParsedData(use -> ${__V(Result_${index}_g1)}

Now, if you want to iterate to all groups, you need another foreach to do that. As you know which group represent what value, you can use this way.