Skip to main content
Learn how to extract dynamic values from responses and use them in subsequent requests - essential for testing realistic user flows.

What is Correlation?

Correlation means extracting values from one response and reusing them in later requests. This is critical for:
  • Session tokens and authentication
  • CSRF tokens and security nonces
  • Resource IDs from created objects
  • Dynamic form values (VIEWSTATE, hidden fields)
  • Transaction IDs and reference numbers
Recorded scripts capture session-specific data that expires quickly. You must correlate these values to create working tests.

Extracting from JSON Responses

Most modern APIs return JSON data. Extract values by parsing the response:
Use res.json() to parse the entire response, or res.json('path.to.field') to extract a specific field directly.

Extracting from HTML Forms

Web applications often include hidden fields with dynamic values. Extract them before form submission:

Method 1: Using Response.submitForm()

The high-level API handles form extraction automatically:

Method 2: Manual Extraction

For more control, extract specific fields manually:
If you set discardResponseBodies: true in options, you must override it per request with {responseType: "text"} to access the response body.

Extracting .NET ViewState and CSRF Tokens

Common pattern for .NET applications:

Generic String Extraction

For responses that aren’t JSON or HTML, extract values using string boundaries:
Extract the first occurrence between boundaries:

Complete Correlation Example

Realistic user flow with multiple correlations:

Advanced Patterns

Sharing Data Between VUs

Extract data in setup, share with all VUs:

Correlation with Multiple Matches

Extract multiple values from a response:

Token Refresh Pattern

Handle token expiration and renewal:

Common Extraction Scenarios

Best Practices

Always Validate Extracted Data

Use Descriptive Variable Names

Handle Missing Values Gracefully

Debugging Extraction

Troubleshoot extraction issues:

API CRUD Operations

See correlation in complete API workflows

HTTP Authentication

Extract and use authentication tokens

Test Lifecycle

Use setup() to share extracted data

API Reference: Response

Response methods for data extraction