What is Correlation?
Correlation is Dynamic Referencing. This is the process of extracting some value from response of a step and referring it into request of other subsequent step.
Why to use Correlation?
For property transfer from one step to another. For example, after login to a website, unique session id is allocated, and this id is required in subsequent steps to interact with the server. So here Correlation will be needed.
How to implement Correlation?
using Regular Expression Extractor, in JMeter you can do correlation.
Steps for implementation.
Step 1 : Create a Test Plan with "Regular Expression Extractor" where you want to do dynamic referencing in JMeter.
Step 2 : Execute the test, and copy response from First Request, navigate to "https://regexr.com/" as we need to provide regular expression in the Regular Expression Extractor from where response value(s) needs to be extracted.
Reference Name: Any name- e.g. ReferenceValue
Regular Expression: to match in the response of first. e.g. href="(.*?)"
Match No.: Your regular expression can match multiple elements, so enter match number to take one. e.g. 14
Default Value: In case no match is found,default will be used. Optional field.
Step 3 : Refer the extracted value (referred by Reference Name) into a subsequent step.
Step 4 : Run and validate the results.