JMeter Correlation
Learn how to handle dynamic values in JMeter test automation through correlation using Boundary Extractor and Regular Expression Extractor.
Mark
Performance Testing Expert
When automating the process of test assets there are often dynamic values that need to be handled through correlation. While LoadRunner provides auto-correlation and Blazemeter offers SmartJMX auto-correlation via proxy, standard JMeter requires manual setup using its extraction processors.
Understanding Correlation
Correlation is the process of capturing dynamic values from server responses and using them in subsequent requests. Common examples include:
- Session IDs
- CSRF tokens
- Dynamic identifiers
- Authentication tokens
Boundary Extractor Method
The Boundary Extractor allows you to extract values by specifying the text that appears before and after the target value.
For example, to extract a value like d41d8cd98f00b204e9800998ecf8427e from a string containing blog-collection-list-, configure the extractor as follows:
| Setting | Value |
|---|---|
| Left Boundary | blog-collection-list- |
| Right Boundary | - |
| Match Number | -1 |
Using match number -1 captures all matching instances as separate variables:
blogcollectionlist_1blogcollectionlist_2- etc.
A count variable is also created to track the total number of matches.
Regular Expression Extractor Method
An alternative approach uses regular expressions for more flexible pattern matching.
For the same extraction, use:
| Setting | Value |
|---|---|
| Regular Expression | blog-collection-list-([a-z0-9]+) |
| Template | $1$ |
| Match Number | -1 |
This generates similarly-indexed variables:
blogcollectionlist_1_g1blogcollectionlist_2_g1
The g1 suffix indicates the capture group assignment.
Using Extracted Values
Both methods enable subsequent test steps to reference extracted values via JMeter variable syntax:
${blogcollectionlist_1}
Or for regex extractions:
${blogcollectionlist_1_g1}
Choosing Between Methods
- Boundary Extractor: Simpler for straightforward extractions where you know the surrounding text
- Regular Expression Extractor: More powerful for complex patterns or when you need multiple capture groups
Further Reading
Tags: