【软件性能测试-LoadRunner实战技能 14】== LoadRunner_Web_reg_save_param function explained_分析

来源:互联网 发布:mac系统怎么删除文件 编辑:程序博客网 时间:2024/06/08 17:22

 

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 casesensitive.

 

NotFound

The handling method when a boundaryis not found and an empty string is generated. “ERROR,” the default,indicates that VuGen should issue an error when a boundary is notfound.

When set to “EMPTY,” no error message is issued and scriptexecution continues. Note that if Continue on Error is enabled for thescript, then even when NOTFOUND is set to “ERROR,” the script continueswhen the boundary is not found, but it writes an error message to theExtended log file.

 

LB

The left boundary of the parameter or thedynamic data. This parameter must be a non-empty, null-terminatedcharacter string. Boundary parameters are case sensitive; to ignore thecase, add “/IC” after the boundary. Specify “/BIN” after the boundaryto specify binary data.

RB

The right boundary of the parameter orthe dynamic data. This parameter must be a non-empty, null-terminatedcharacter string. Boundary parameters are case sensitive; to ignore thecase,

add “/IC” after the boundary. Specify “/BIN” after the boundaryto specify binary data.

 

RelFrameID

The hierarchy level of the HTML page relative to the requested URL.

 

Search The scope of the search—where tosearch for the delimited data. The possible values are Headers (searchonly 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 theordinal or occurrence number of the match. The default ordinal is 1. Ifyou specify “All,” it saves the parameter values in an array.

 

SaveOffset

The offset of a sub-string of thefound value, to save to the parameter.

The default is 0. The offsetvalue must be non-negative.

 

Savelen

The length of a sub-string of thefound value, from the specified offset, to save to the parameter.

Thedefault 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:

Suppose the script contains a dynamic session ID:

 

web_url(“FirstTimeVisitors”,”URL=/exec/obidos/subst/help/first-time-visitors.

html/002-8481703-4784428>Buybooks 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 apenny”, “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 lookslike this,

where user_access_number is the name of the parameterrepresenting 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 laterpoint in the script generates new dynamic data,

you must insert anothercorrelation function.

Also as I wrote in my last post don’t confuse correlationwith parameter

which you might have used in tools like QTP to passvarying 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 dynamicdata.                                                This string defines the left boundary of the dynamic data.
  • Identify the string that is immediately to the right of the dynamicdata.                                       This string defines the right boundary of the dynamic data.
  • web_reg_save_param looks for the characters between (but notincluding) the specified boundaries and saves the information beginningone byte after the left boundary                      and ending one byte before the rightboundary. web_reg_save_param does not support embedded boundarycharacters.

For example, if the input buffer is {a{b{c} and “{” isspecified as a left boundary, and “}” as a right boundary, the firstinstance is c and there are no further instances—it found the right andleft boundaries but it does not allow embedded boundaries, so “c” isthe only valid match. By default, the maximum length of any boundarystring is 256 characters.
Include a web_set_max_html_param_len function in your script toincrease the maximum permitted length. For example, the followingfunction increases the maximum length to 1024 characters:web_set_max_html_param_len(“1024”);