JMeter regex extractor forEach controller

风格不统一 提交于 2020-01-10 19:57:28

问题


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)


回答1:


You have to reference the variable with the function:

${__V(Result_${index}_g1)



回答2:


...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)



回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/10582100/jmeter-regex-extractor-foreach-controller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!