๐ Correlation & Realism ยท Days 13โ18
Day 13: Dynamic Correlation
Objective
Extract a dynamic token or ID from a response and reuse it downstream.
Scenario
Send a request that returns a token, session ID, or CSRF token. Extract it with a regular expression or JSON extractor. Use it in the next request.
Metrics to Watch
When It Clicks
Hardcoded session values break the moment the server rotates them.
Solution
In JMeter: add a Regular Expression Extractor (or JSON Extractor) post-processor to the first request. Set the reference name to 'token', the expression to match the dynamic value (e.g. `"token":"(.+?)"` for a JSON response). Reference it downstream as `${token}`. To confirm correlation works: add a Debug Sampler after the extractor and inspect the variable value in View Results Tree. If the variable shows 'FAILED' the regex did not match - adjust the expression.
Reflection
What happens if you replay a recorded script without extracting dynamic values?
Deliverable
A script that extracts and reuses a dynamic value across requests.
โ ๏ธ Never run load tests against infrastructure you do not own or have explicit written permission to test. Always use a dedicated test environment. Unauthorized load injection can cause outages, trigger legal liability, and violate terms of service.