Correlation overview
Creating a Vuser script includes the steps shown below. This topic provides an overview of the third step, correlating a Vuser script.
Correlation - handling dynamic data
Web pages sent from the server to the browser often contain dynamic data that the client must return in later requests. The process of locating, extracting and replacing recorded dynamic values with values valid at replay is called correlation.
Common examples of dynamic data are:
- Session ID
- Timestamp
- Customer ID
- Authentication token
This information generally becomes invalid when the session is completed. At the next session, the same items are sent, but the values are different.
After recording the business process in LoadRunner Professional, the script might contain dynamic values in the arguments of the generated API functions. When the script is replayed, these recorded values are sent to the server. However, the web server rejects them because they are not valid in the replay session. Generally, when this happens, the test fails.
Example of a dynamic value as received from the server and as it appears in the recorded script:
Response Body
Resulting script
To enable successful replay, the script must:
- Locate the dynamic data in the server responses, including headers.
- Extract and save that dynamic data.
- Replace the hard-coded dynamic data from the recording session with the data from the current replay session.
Dynamic data is located using boundaries definitions, regular expressions, attributes, XML queries, or JSON queries as appropriate. The data is extracted and the value is saved to a parameter. The parameter is used instead of the recorded value in later requests to the server.
Some of the correlation is handled automatically by VuGen. You can configure the automatic correlations. For more information on how to configure VuGen to handle correlations, see Automatic correlation and Automatic correlation configuration.
Dynamic data that is not correlated automatically requires your intervention. For more information, see Manually correlate scripts and Design Studio.
If the script still fails on correlation problems, you can use the advanced techniques. For more information, see Advanced correlation techniques.
Note: Although parametrization and correlation both use LoadRunner Professional parameters, the purpose is different.
- Parameterization is used to vary the requests based on a list of values you provide. Parameterization is not dependent on preceded responses from the server.
- Correlation uses data from the server in subsequent requests so that the server does not reject the request.
See also: