How should JMeter handle dynamic value (correlation)?
The term “map” describes how dynamic values received from the server are processed. This dynamic data, such as session ID and authorization token, are the distinguishing values that are generated by the server for security purposes. Dynamic values can also relate to site content, such as dropdown options, dates, item and product IDs, order numbers, etc. You can capture these dynamic values through the map and pass them on to subsequent lookups. This is the fundamental idea behind “Correlation” in JMeter.
What are the typical values that require correlation?
- Access form
- Session ID
- Customer name or identification number
- Order number Account number
- The number of records displayed on a page
- Time and date
How should JMeter handle dynamic value (correlation)?
In correlation, there are 3 main stages, which are as follows:
1. How can I record a JMeter script? (script)
2. Identification (of a dynamic value
3. Implementation of the correlation logic
identification dynamic value identification. Locating dynamic values in JMeter and storing them in a variable requires two components. These components are Listener and Postprocessor. The list of post-processors is given below. You can use any of the post processors depending on your preferences and needs: Postprocessor
Regular Expression Extractor
- Boundary Extractor
- JSON Extractor
- JSON JMESPath Extractor
- CSS Selector Extractor
- XPath Extractor XPath2 Extractor
- Listener
View Results Tree (Used during script recording)
Dynamic value identification procedures:
1.Add a listener for “View Results Tree” under the thread group.
2. Choose the ‘Stop thread’ option under ‘Action after sample error’ in the Thread group.
3. Make sure that the Loop Count, Throttle Period, and Number of Threads (Users) inputs are all 1.
4. The script may stop working on a specific sample where correlation is needed.
5. View the script and select the sample that failed during playback.
6. You will receive several parameter passing requests along with their values.
7. The value of the parameter must be copied into the ‘Value’ column.
Step 1: View the captured ‘View Result Tree’ listener.
Step 2 – Insert the copied value into the listener search field of the recorded view result tree, and then click the “Search” button.
In the third step, JMeter marks the request that contains this value. Select the first request that is highlighted.
Step 4. Select the “Response Details” tab.
Step 5 – Select the ‘Response Body’ tab from the ‘Response Data’ menu.
Step 6 – Paste the same value again into the search area of the Response Body.
Step 7: Select “Search” from the menu. Check the location in the response body where this dynamic value appeared. The search value is underlined.
Step 8 – After JMeter determines the value in the response body, copy the string to create a special regular expression.
Step 9 – Create a regular expression declaration that can capture the dynamic value. The regular expression declaration in this case is:
domainID=([0-9a-z-]+)&
Step 10: Confirm that the regular expression is correct.
1. Type the same regular expression in the search box of the sampler response (Recorded View Results Tree Listener) to confirm that the regular expression is correct.
2. Check the “Regular exp” option. checkbox
3. Hit the “Find” button.
1. Also, you can choose the “RegExp Tester” option from the result detector dropdown menu.
2. The regular expression statement must be pasted.
3. ‘Test’ should be clicked.
The result in both situations should draw attention to the correct dynamic value.
Once you have found all the dynamic values, repeat these procedures.
The implementation is currently in the third phase.
How to implement the correlation:
To do this, add a regular expression extractor under the same sample whose response contains the dynamic value, and place the regular expression declaration (from step 9) in the ‘Regular Expression’ field. Next to the template, the matching number, and the default value, add the name of the newly formed variable.
2.The final step is to use the syntax {$RegExVaribaleName>} to replace every instance of dynamic values in subsequent requests. Refer to the image below:
3. Rerun the script to confirm that the correlation is accurate. You can also add a debug sampler or refer to the view results tree listener.
The existence of dynamic values may occur in one of three scenarios. Each situation requires a somewhat unique strategy.
- Dynamic value in the request body
- Dynamic value in the request URL
- Dynamic value in the redirected request