Correlation in Loadrunner: Ultimate Guide

Correlation, as the name suggest, is a mechanism of defining relationship between two variables or entities. Dictionary defines it as “statistical relation between two or more variables such that systematic changes in the value of one variable are accompanied by systematic changes in the other”.

Let’s understand co-relation with the following scenario

Consider you are recording a script using Loadrunner

Client- Server Communication

1) During Record, client sends a request to the server to start a session

2) Server receives the request, and allocates a new session ID ABC

3) Client stores the session id ABC in the script.

4) Client start the session with ID ABC, and send request to server to allow it to record

5) Server recognizes the ID ABC and allows client to record the script

Now, let’s study the client server communication during replay

1) During Replay, client sends a request to the server to start a session

2) Server receives the request, and allocates a new session ID XYZ

3) Client start the session with previously recorded session ID ABC, and send request to server to allow it to record

4) Server is unable to identify the ID ABC as it was expecting ID XYZ that it has allocated and session fails.  

We need a solution, which to capture parse the dynamic value sent at run-time and return this value back to server. Here is how the client-server communication will look like with this solution

1) During Replay, client sends a request to the server to start a session

2) Server receives the request, and allocates a new session ID ZZZ

3) Client parses this new session id ZZZ from the request.

4) Client sends a request to start session with id ZZZ

5) Server recognizes the ID ZZZ and allows client to replay the script

 This is nothing but correlation.

Please be patient . Video will load in some time. If you still face issue viewing video click here

In case of VUGen, correlation is binding relationship between a response and any preceding request.

There are various situations when a request is based on a previously received response from the server, such as, a Session ID, server date/time which is fetched from server. These values are different every time you run application or record a script. Obviously, if the execution of script depends upon a value returned by server, it means you need to find a mechanism where you can “catch” the server response and attach to those requests which server expects. This is typically called Correlation in LoadRunner.

In simple words, the solution by using Correlation is:

1. Capture output value from a step

2. Use above captured value to serve as input to all subsequent steps

Correlation is classified into 2 categories in VUGen/LoadRunner:

Automatic correlation

Manual correlation

Automatic Correlation


LoadRunner provides a mechanism to easily perform correlation in automatic fashion.

VUGen will require you to run a recorded script at least 2 times so it can internally compare the varying values in server response.

Automatic correlation can be classified into 3 categories:

1. Auto-Detect Correlation

2. Rule-Based Correlation

3. Correlating All Statements

Rule Name

When to Use

Auto-detect Correlation

Detect and correlate dynamic data for application servers supported by HP LoadRunner


Used when working with a non-supported application server for which the context is known.

Correlate All

Helps correlate all dynamic data in blind fashion.

Though Automatic Correlation seems simpler, it can be error prone and works in not more than 5% of the cases. It is always advisable to use manual correlation.

To configure automatic correlation at the time of recording, perform below configuration in Record Time Setting after a script has been recorded.

Click on Record =>Recording Options (or click Ctrl +F7),

>Description: E:ChromeISServicesContent_Writing_SEOGuru994_What_is_Correlation_and_why_is_it_a_mustimages1_Recording_Options_menu.png

Below window will open:

Description: E:ChromeISServicesContent_Writing_SEOGuru994_What_is_Correlation_and_why_is_it_a_mustimages2_Recording_Options.png

Click on Correlation =>Configuration – below window will open.

Description: E:ChromeISServicesContent_Writing_SEOGuru994_What_is_Correlation_and_why_is_it_a_mustimages1_Correlation_Rules.jpg

Here, you need to mark as checked against all applications (ASPNET) etc., which are used in your subject application. On the right hand side, you can see the rules which will detect possible candidates for correlation e.g. _VIEWSTATE. You can also add more applications or custom rules by clicking on New Rule button.

You can also click on RULES, you will see as below:

Description: E:ChromeISServicesContent_Writing_SEOGuru994_What_is_Correlation_and_why_is_it_a_mustimages4_Record_Correlation_settings.jpg

In order for Automatic Correlation to work, you need to ensure Rules Scan is marked as checked. If you click on automatically correlate values found, VUGen will not prompt you with choice once a correlation candidate is found, instead, it will just correlate them.

We will understand API used for correlation later. However, it is advisable to use HTML comparison instead of text comparison.

Once you’ve selected any rules, click on OK button to close the windows.

Click on Description: E:ChromeISServicesContent_Writing_SEOGuru994_What_is_Correlation_and_why_is_it_a_mustimages1_Recording_Options_menu2.pngfrom menu and VUGen will regenerate script (without having to record) with new configurations. VUGen will automatically add required piece of code to handle correlation. We will look at the sample in more detail in Manual Correlation.

Please note, if you perform correlation manually or use automatic correlation, the piece of code will contain exactly same syntax and function.

Steps to auto correlate a script:

1. Record a script

2. Replay script

3. Identify the values to be correlated

4. Select the values and click the auto-correlate button

5. Verify the script by running again. A successful run means successful correlation.


Correlation helps run your script with different values

Correlation also reduces the size of your script

Manual Correlation

Manual correlation is about writing code directly into your script to cater for ever-changing values. We can split it into below steps:

1. Determine the value to capture

2. Find the right and left text boundaries of the value to capture (WEB)

3. Find which occurrence of the text boundaries should be used

4. Add a web_reg_save_param function to the script, above the piece of code which requests the page with the value to capture

5. Add a parameter name, left boundary, right boundary, and occurrence to the function

6. Parameterize the dynamic value in the script every time it occurs

7. Verify correct execution

Manual correlation can be done by VUser Comparison. Steps in VUser Comparison method of Correlation can be split as below:

1. Identify Dynamic values that need to be correlated

2. Find Servers response containing the Dynamic value

3. Capture the Dynamic value in a parameter

4. Replace every occurrence of the Dynamic value with the parameter

5. Verify Changes

Understanding Web_reg_save_param function

VUGen provides multiple functions or APIs to correlate candidates, including:





While a brief introduction is being provided here, for detailed understanding of functions and their parameters, open VUGen, write function (or use Steps Toolbox), move cursor on the function and click F1 – get yourself acquainted with VUGen help and make a habit. You will have to deal with it a lot when working in the industry.

Here we go with the function details:

web_reg_save_param(Parameter Name , Left Boundary , Right Boundary )

List of Attributes

Convert:The possible values are:

HTML_TO_URL: convert HTML-encoded data to a URL-encoded data format

HTML_TO_TEXT: convert HTML-encoded data to plain text format; this attribute is optional.

Ignore Redirections: If "Ignore Redirections=Yes" is specified and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location, and the search is performed on the response from that location.

This attribute is optional. The default is "Ignore Redirections=No".

LB:The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case-sensitive. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

NOTFOUND: The handling option when a boundary is not found, and an empty string is generated.

"Not found=error", the default value, causes an error to be raised when a boundary is not found.

"Not found=warning" ("Not found=empty" in earlier versions), does not issue an error. If the boundary is not found, it sets the parameter count to 0 and continues executing the script. The "warning" option is ideal if you want to see if the string was found, but you do not want the script to fail.

Note: If Continue on Error is enabled for the script, then even when NOTFOUND is set to "error", the script continues when the boundary is not found, but an error message is written to the extended log file.

This attribute is optional as well.

ORD: Indicates the ordinal position or instance of the match. The default instance is 1. If you specify "All," it saves the parameter values in an array. This attribute is optional.

Note: The use of Instance instead of ORD is supported for backward compatibility, but deprecated.

RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case-sensitive. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

RelFrameID: The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. Click RelFrameID Attribute for a detailed description. This attribute is optional.

Note:RelFrameID is not supported in GUI level scripts.

SaveLen: The length of a sub-string of the found value, from the specified offset, to save to the parameter. This attribute is optional. The default is -1, indicating to save to the end of the string.

SaveOffset: The offset of a sub-string of the found value, to save to the parameter. The offset value must be non-negative. The default is 0. This attribute is optional.

strong>Search: The scope of the search-where to search for the delimited data. The possible values are Headers (Search only the headers), Body (search only body data, not headers), No resource (search only the HTML body, excluding all headers and resources), or ALL (search body, headers, and resources). The default value is ALL. This attribute is optional but generally preferred.

comments powered by Disqus

Follow Us!


Your Feedback & Ideas are very important to us. Please share your suggestions here