In this blog post we will see how to correlate in loadrunner manually and how to replace the dynamic value in the script. Please read my earlier post before you read further.
What is correlation?
Correlation is the process of finding dynamic values (such as session value in the form of JSESSION, VIEW STATE etc.) in the response and passing it to subsequent requests.
For example, if you login into ICICI Bank, you could see there will be a parameter jsessionid={xxxx_some_dynamic_valu_xxxx}
If you replay your script without correlation, VuGen cannot replay, because jsessionid parameter is dynamic, new and unique. If the script sends this parameter to web server; webserver will not accept it, and the subsequent requests will fail.
When correlation parameter is created, VuGen adds a functions usually web_reg_save_param_*, that extracts the dynamic value and then it stores into a parameter.
How to perform manual correlation?
Following are the different ways which helps to identify the string which needs to be correlated:
- By comparing the scripts
- Using Replay log search
1.    By comparing the scripts
WDiff utility is the default from HP which helps to compare scripts. Follow below steps to identify the string:
- Record your identical business flow twice.
- Save your script, say Your_Script_Name_A and Your_Script_Name_B
- Navigate to Tools > Compare with script…
2. Using Replay log search
Follow below scripts to identify the dynamic values using replay log search.
- Scan the script
- Go to generation log which displays response from the server
- Search the extended replay log for the response. Check to see if this response contains a different string within the same boundaries as the original. If yes, this string requires correlation, else it is not required to correlate.
 How to correlate manually web scripts?
Below is the snapshot of my Web Tours business flow. Here I have identified the dynamic value i.e. userSession. We will see how to correlate this userSession parameter.
Follow below steps to manually correlate the script?
1. Execute your script at least once.
2. Copy the text userSession or the parameter value
3. Select the previous request as shown below
4. Switch to Tree View in VuGen
5. Click on Show Replay Snapshot
6. Select each HTTP flow and search for the copied value as shown below.
7. In our example, I have identified the dynamic value in /WebTours/nav.pl?in=home HTTP flow.
8. Follow below guidelines before you read further.
- Analyze the location of the dynamic data in the response.
- Identify the string that is immediately to the left of the dynamic data. This string is called left boundary of the dynamic data.
- Identify the string that is immediately to the right of the dynamic data. This string is called right boundary of the dynamic data.
- The right and left boundaries should be as UNIQUE as possible to identify the strings.
9. Select the string in the HTTP response
10. Right click on it and select Create Correlation as shown below.
11. VuGen displays below pop-up with Selected Value, Left boundary and Right boundary. Earlier versions of LoadRunner don’t show this pop-up. Engineers have not defined themselves.
12. Verify the Left boundary and Right boundary and then click on Yes.
13. Switch to Script View, you could see below function has been added in the script.
//Correlation comment – Do not change!Original value=’109968.071607938fzfzticpziDDDDDDDDQDipiQzV’ Name =’CorrelationParameter_1′
web_reg_save_param_ex(
“ParamName=CorrelationParameter_1”,
“LB=userSession value=”,
“RB=>\n<table border”,
SEARCH_FILTERS,
“Scope=Body”,
“RequestUrl=*/nav.pl*”,
LAST);
14. This function extracts the dynamic value and store it in the parameter CorrelationParameter_1
15. It is best practice to name the correlation parameters using naming conventions. Here I changed to Web_Tours_Login.
16. Next step is to replace the dynamic value with the correlation parameter. Correlation parameter should be always covered with curly braces {correlation_parameter}
17. Press CTRL + H. Enter the dynamic value in Find What: and the correlation parameter in Replace With: fields as shown below.
18. Carefully replace the values one by one.
19. Now execute your script to validate.
20. Below is the difference in the replay with and without correlation parameter.
Without Correlation Parameter |
 |
With Correlation Parameter |
 |
How to validate the script?
Once the execution completed, switch to Tree View. Click on Show Record and Replay Snapshots and the click on HTML View. Both the snapshots should be identical for all the requests as shown below.
Request One
Request Two
Thanks for visiting QAInsights!
We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything.
Subscribe to our QAInsights YouTube Channel. Subscribe our free weekly newsletter or Google feeds