View on GitHub

extract information from response

using Regular Expression Extractor & ForEach controller in jMeter

Download this project as a .zip file Download this project as a tar.gz file

‹ back to table of content

Here you've got lessons' files.

Regular Expression Extractor

Sometimes you want to click in each link on page. You need to extract URL from response. It'll be simple if you have basic knowledge of RegExp. If you don't know what the RegExp is, please look at You need to add Regular Expression Extractor into your sampled page - presented on following screen.

jMeter adding regular expression extractor

After that, you should configure the new element. It's simple! You have to specify your variable name. I'm using now URLS as name. Result of regular expression extractor will be available as ${URLS}. We have also a pattern which looks like:

<a href="([^"]+)"> and it means - give me all characters between quotation marks. In this case it'll be URL address. Next important parameter is a template. It's a order of your regex "unknown value". We have got only one parameter so template looks like $1$. But sometime you have more than one value. Then you have to use $1$$2$$3$. You can do what you want :) For example - you've got <a href="([^"]+)" class="([^"]+)"> and template: TEXT$2$SPACE$1$.html . For response looks like: <a href="test" class="Class"> The result will be: TEXTClassSPACEtest.html It's easy way to transform regex result. Isn't it?

configuring regular expression extractor

ForEach controller

The ForEach controller is really easy to use. You have to specify only three parameters.

foreach controller

On following screen you have simple sampler with new variable ${URL}

sampler with dynamic url

Now you're able to open all links from your page, but be careful, It can generate a huge load on the server. Also don't forget about asserting the result!

‹ back to table of content

comments powered by Disqus