Correlation:
- Dynamic values such as Cookies , Checksums , Session Id's change each time you use an application
- During Script Replay, the recorded dynamic values do not match the actual dynamic values and your script fails
- To avoid failure, you must parametrize the dynamic values and use the parametrized values for further communication between client and server
- This is nothing but CORRELATION
Saves dynamic data information to a parameter.
Session id: Session id is created by the server for security purpose.
Dynamic values created by server
Create 2 identical scripts of same business scenario and compare then we can see the difference in the dynamic values in the yellow lines
Manual: Web_reg_save_param (const char “Param_Name”, <List of Attributes>, LAST);
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.
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.
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), Noresource (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.
Case of saving a single string
/*This Web_reg_save_param call applies to the following action function: Web_submit_form. */
Web_reg_save_param (“outFlightVal",
"LB=outbound Flight value=", "RB= checked >", LAST);
Web_submit_form ("reservations.pl", "Snapshot=t4.inf", ITEMDATA,
"Name=depart", "Value=London", ENDITEM,
"Name=depart Date", "Value=11/20/2003", ENDITEM,
"Name=arrive", "Value=New York", ENDITEM,
"Name=return Date", "Value=11/21/2003", ENDITEM,
"Name=numPassengers", "Value=1", ENDITEM,
"Name=roundtrip", "Value=<OFF>", ENDITEM,
"Name=seatPref", "Value=None", ENDITEM,
"Name=seatType", "Value=Coach", ENDITEM,
"Name=findFlights.x", "Value=83", ENDITEM,
"Name=findFlights.y", "Value=16", ENDITEM,
LAST);
/*
The result of the web_reg_save_param having been called before the web_submit_form is: Action.c (15): Notify: Saving Parameter "outFlightVal = 230; 378; 11/20/2003"
*/
// Now use the saved outFlightVal
web_submit_form ("reservations.pl_2",
"Snapshot=t5.inf",
ITEMDATA,
"Name=outboundFlight", "Value= {outFlightVal}", ENDITEM,
"Name=reserveFlights.x", "Value=92", ENDITEM,
"Name=reserveFlights.y", "Value=10", ENDITEM,
LAST);
/*
Action.c (34): Notify: Parameter Substitution: parameter "outFlightVal" = "230; 378; 11/20/2003" */
Correlation (Dynamic session handling)
Mechanism of capturing a value dynamically and replacing it in the script during replay
Or
To capture the dynamic values in each run of the script execution is called correlation.
Or
To parameterize the server generated values
Correlation:
To capture the dynamic values in each run of the script execution is called Correlation.
L R has two types of correlated mechanism.
1. Auto Correlation,
2. Manual Correlation
1. Automatic Correlation:
Automatically the L R itself handles the process to capture the dynamic value in each run of the script execution.
Create the script by disabling the correlation in the recording options.
Try to run the script should show the error messages like Sessions expired, Session timeout.
Click on find correlation it displays the required dynamic values in the co relation studio.
Select the value to be correlated and Click on correlate.
The Correlation Function will be inserting in appropriate place of the script like below…
Syntax: Web_reg_Save_Param (“P name”,”L B”,”R B”,”ORD=”)
Here Web --- web protocol,
Reg --- register,
Save – save,
Param -parameter,
P name – parameter name,
Assign the name of the parameter which is related by the hard coded dynamic values.
LB ---Left boundary = Assigns the Left Boundary of the dynamic value.
RB --- right boundary = Assigns the Right Boundary of the dynamic value.
Ord --- ordinal value
It indicates the no of occurrences of the dynamic values.
Ex: if the occurrence is 1, ord = 1.
If the occurrence is 2 ord = 2.
If n no of occurrences then ord = all.
LAST --- it come for each function at last time, it is end of the attributes.
It indicates there is no any arguments which in the function.
Manual Correlation:
Create the 2 identical scripts and save those 2 scripts in windows temp directory.
Open any one of the script from the script go to Tools menu.
Select compare script for the comparisons, the difference between the two scripts will display in the Wdiff utility.
Identify the dynamic context charge between two scripts identically the Left & Right boundary of the dynamic values.
Search for the First occurrence of the dynamic values to replace by a given parameter name.
Select the position to insert the correlated function with all the parameters.
Try to run the script, the script should properly run without the script showing any error message for the dynamic handling.
When will you use manual correlation?
Dynamic values will be encrypted sometimes, so we use manual correlation instead of automatic correlation.
How can we do manual correlation?
By comparing two identical scripts.
Where the correlation functions will be inserted?
Before submitting the form or data. Where we are giving input before that we are putting the function.
Note: After scanning or running of the script, we will get some messages found like
1. No server found
2. No request found
3. Request link not found
4. Web link not found.
Then we will go to execution log and find out about these messages clearly.
What is LB? What is RB? How did you get it?
LB: It is the left boundary of the dynamic value.
RB: It is the gives the Right boundary of the dynamic value.
I will go to tree view then I will select server response from there I will select the LB and RB as indicated.
What is ORD?
Number of occurrence of the dynamic value.
How did you do correlation?
Automatic correlation and manual correlation.
Note: After scanning or running of the script, we will get same messages found like
1. No server found
2. No request found
3. Request link not found
4. Web link not found.
Then we will go to execution log and find out about these messages clearly.
Correlation:
1. Cntrl + f -> find
2. Cntrl + H-> find & replace, f3 -> to go for next session value
3. F3->Next search -> forward search
4. Shift+F3-> backward search
5. Ctrl +s ->to save