Search code examples
jmeterjmeter-pluginsjmeter-5.0

How to setup nested ForEach Controller and send sub-request on JMeter


I have 3 types of request,

request 1: www.test.com/data  

will return data in JSON Array

 request 2: www.test.com/img/{img_id} 

{img_id} comes from items return by request 1, and requst 2 will return an {uid}

 request 3: www.test.com/test/{uid}

I use jmeter to test this flow, now I was able to send request 1 and then use ForEach Controller to send some request 2, but I don't how to send request 3 according to the response of each request 2

I'm newbie to JMeter , Is anyone could help , Thanks


Solution

  • You need to add one more ForEach Controller nested in the previous one. So your Test Plan structure will be looks like:

    Thread Group  
        Request 1  
            RegExpExtractor 1  
        ForEach Controller 1  
            Request 2  
                RegExpExtractor 2
            ForEach Controller 2  
                Request 3
    

    You may use Regular Expression Extractor with -1 as a Match No. parameter to use it in ForEach Controller (from RegExpExtractor 1 to ForEach Controller 1 and from RegExpExtractor 2 to ForEach Controller 2).

    Check this Test Plan as an example.