Search code examples
jmeterperformance-testingload-testing

JMeter reponse headers values before redirection on status code 302


I am performing load testing on an API using JMeter. For that, I call an oauth link, which returns a code in the headers which I use for further testing. But the link redirects to another link and I am unable to capture the value of the response headers when a response with status code 302 is returned. How can I do that.


Solution

  • If your situation is like this one:

    JMeter Redirect

    You can still extract the dynamic value from the latter sample result by modifying Regular Expression Extractor scope

    As per documentation:

    Apply to:

    This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.

    • Main sample only - only applies to the main sample

    • Sub-samples only - only applies to the sub-samples

    • Main sample and sub-samples - applies to both.

    • JMeter Variable - assertion is to be applied to the contents of the named variable

    By default Regular Expression Extractor is looking into Main sample only, in the above example it is HTTP Request, if the data you're looking for is stored in one of the sub-samples it is enough to change Regular Expression Extractor's scope to look into sub-results as well:

    JMeter RegEx Sub Results