web_reg_save_param function explained
Sponsored Links
As explained in one of my previous posts, web_reg_save_param is THE most important function when you are working with LoadRunner. We will start with the syntax and then touch upon some examples to get a clear idea.
int web_reg_save_param (const char *mpszParamName, <List of Attributes>,LAST);
Find below the available attributes [<List Of Attributes>]. Note that the attribute value strings (e.g. Search=all) are not case sensitive.
NotFound The handling method when a boundary is not found and an empty string is generated. “ERROR,” the default, indicates that VuGen should issue an error when a boundary is not found. When set to “EMPTY,” no error message is issued and script execution continues. Note that 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 it writes an error message to the Extended log file.
LB The left boundary of the parameter or the dynamic data. This parameter must be a non-empty, null-terminated character string. Boundary parameters are case sensitive; to ignore the case, add “/IC” after the boundary. Specify “/BIN” after the boundary to specify binary data.
RB The right boundary of the parameter or the dynamic data. This parameter must be a non-empty, null-terminated character string. Boundary parameters are case sensitive; to ignore the case, add “/IC” after the boundary. Specify “/BIN” after the boundary to specify binary data.
RelFrameID The hierarchy level of the HTML page relative to the requested URL.
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), or ALL (search Body and headers). The default value is ALL.
ORD This optional parameter indicates the ordinal or occurrence number of the match. The default ordinal is 1. If you specify “All,” it saves the parameter values in an array.
SaveOffset The offset of a sub-string of the found value, to save to the parameter. The default is 0. The offset value must be non-negative.
Savelen The length of a sub-string of the found value, from the specified offset, to save to the parameter. The default is -1, indicating until the end of the string.
Convert The conversion method to apply to the data:
HTML_TO_URL: convert HTML-encoded data to a URL-encoded data format
HTML_TO_TEXT: convert HTML-encoded data to plain text format
Examples:
The examples below are taken from the LoadRunner tutorial to give clarity on topic. We will see more examples in the coming posts.
Sample Correlation for Web Vusers
Suppose the script contains a dynamic session ID:
web_url(”FirstTimeVisitors”,”URL=/exec/obidos/subst/help/first-time-visitors.html/002-8481703-4784428>Buy books for a penny “, “TargetFrame=”,”RecContentType=text/html”,”SupportFrames=0″,LAST);
The dynamic id here is 002-8481703-4784428
You insert a web_reg_save_param statement before the above statement:
web_req_save_param (”user_access_number”, “NOTFOUND=ERROR”,”LB=first-time-visitors.html/”,”RB=>Buy books for a penny”, “ORD=6″,LAST);
ORD=6 saves the sixth occurrence of the value in user_access_number. I think everything else is self explanatory
After implementing correlated statements, the modified script looks like this, where user_access_number is the name of the parameter representing the dynamic data.
web_url(”FirstTImeVisitors”,”URL=/exec/obidos/subst/help/first-time-”“visitors.html/{user_access_number}Buy books for a penny “,
“TargetFrame=”,”RecContentType=text/html”,”SupportFrames=0″,LAST);
Note: Each correlation function retrieves dynamic data once, for the subsequent HTTP request. If another HTTP request at a later point in the script generates new dynamic data, you must insert another correlation function.
Also as I wrote in my last post don’t confuse correlation with parameter which you might have used in tools like QTP to pass varying values. Parameter is not a dynamic value captured from server response but it is something for which the user has predefined data values available.
Tips to identify the dynamic string boundaries:
- Always analyze the location of the dynamic data within the HTML code itself, and not in the recorded script.
- Identify the string that is immediately to the left of the dynamic data. This string defines the left boundary of the dynamic data.
- Identify the string that is immediately to the right of the dynamic data. This string defines the right boundary of the dynamic data.
- web_reg_save_param looks for the characters between (but not including) the specified boundaries and saves the information beginning one byte after the left boundary and ending one byte before the right boundary. web_reg_save_param does not support embedded boundary characters.
For example, if the input buffer is {a{b{c} and “{” is specified as a left boundary, and “}” as a right boundary, the first instance is c and there are no further instances—it found the right and left boundaries but it does not allow embedded boundaries, so “c” is the only valid match. By default, the maximum length of any boundary string is 256 characters.
Include a web_set_max_html_param_len function in your script to increase the maximum permitted length. For example, the following function increases the maximum length to 1024 characters: web_set_max_html_param_len(“1024”);
Comments
13 Comments on web_reg_save_param function explained
-
Senthil on
Tue, 17th Jun 2008 1:23 pm
-
Ankur on
Tue, 17th Jun 2008 2:31 pm
-
senthilkumar.v on
Tue, 17th Jun 2008 9:06 pm
-
Ankur on
Tue, 17th Jun 2008 9:28 pm
-
senthilkumar.v on
Tue, 17th Jun 2008 10:26 pm
-
aravind on
Wed, 6th Aug 2008 1:10 pm
-
Sumit Arneja on
Mon, 1st Sep 2008 8:14 pm
-
lrperftest on
Thu, 11th Sep 2008 11:30 pm
-
What is Correlation in Load Testing? | Load Runner on
Tue, 14th Oct 2008 11:22 am
-
praveen on
Mon, 27th Apr 2009 9:30 am
-
Rajasekhar on
Tue, 28th Apr 2009 2:28 pm
-
Nilanjan ghosh on
Fri, 4th Sep 2009 11:53 am
-
Ajay Saini on
Fri, 30th Oct 2009 9:55 am
Hi,
I’ve a doubt here. In my sripts i’ve identified the dynamic value and tried correlation. The issue i faced here is the same dynamic values present with differnt boundary values. Do i need to include different functiona for earch or shall i use the same function throught out.
dynamic boundaries with different boundary values…Can you elaborate more on this?
probably you can consider using DIG flag in WRSP
Adding more to comments 2:
I’m working on a banking application, where the script has generated an dynamic value in the login page with different boundaries. The same values appears in across the page with different boundaries. I got confused with this. I tried different correlation for all the values.
Please let me know if you need more clarification.
well, I was looking for the boundaries you were getting.
anyways, can you show me the code? Please ensure proper formatting.
Sorry i don’t av the code. Let me update you tomorrow.
Please can anyone suggest me good training centers for Load Runner in Bangalore
Hello.
I am facing some problem to dealt with Correlation.
The dynamic value is not present in the server response of any of the previous request in generation log.
Can any body explain me how to get it’s boundry whwn u r not recieving these dynamic valuse in the previous request.
senthilkumar:
Fine following link ….you mat get solution for your question.
http://motevich.blogspot.com/2007/10/loadrunner-scripts-correlation-tutorial.html
[...] compatibility. The first function is used often. We will touch upon details of this function in the next post… March 14, 2008 | Filed Under [...]
hi,
let me know how to find the dynamic values in winsock vuser script.
Hi ,
abouve information is very useful , thanks for that
if anybody (Beginners) need help , can post quires to following id
rajasekhar.thallapaka@in.ispace.com
or can contact to 09000890326.
regards,
rajasekhar.T
I want to know when we use LB or RB as LB/IC or RB/DIG ?
Also can you please inform me if there is any other such kind of things.
It would be help full if I have a list of these.
hello,
In the function web_reg_save_param can we have a variable value for “SaveLen” parameter
like SaveLen>8
That is, those values with length greater than 8
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
