个人网站: www.7dtest.com 7点测试群:(61369656)------(77273408)------(35710365)------(9410090)

提出这个函数来让自己记住:web_reg_save_param

上一篇 / 下一篇  2007-03-22 18:51:51 / 个人分类:Zee的生活

Theweb_reg_save_paramfunction is aService functionused for correlating HTML statements in Web scrīpts.

Clickherefor an overview on Correlation.

web_reg_save_paramis a registration type function. It registers a request to find and save a text string within the server response. The operation is performed only after executing the nextaction function, such as web_url.

web_reg_save_paramis only recorded when correlation during recording is enabled (see VuGen's Recording Options). VuGen must be in either URL-based recording mode, or in HTML-based recording mode with theA scrīpt containing explicit URLs onlyoption checked (see VuGen's Recording Options).

This function registers a request to retrieve dynamic information from the downloaded page, and save it to a parameter. For correlation, enclose the parameter in braces (e.g. "{param1}") in ensuing function calls which use the dynamic data. The request registered byweb_reg_save_paramlooks for the characters between (but not including) the specified boundaries and saves the information that begins at the byte after the left boundary and ends at the byte before the right boundary. If you expect leading and trailing spaces around the string and you do not want them in the parameter, add a space at the end of the left boundary, and at the beginning of the right boundary. For example:

For example, if the Web page contains the string, "Where and when do you want to travel?", the call:

web_reg_save_param("When_Txt", "LB=Where and ", "RB= do",

              LAST);

with a space after "and" and before "do", will result in "when" as the value of When_Txt. However,

web_reg_save_param("When_Txt", "LB=Where and", "RB=do",

              LAST);

without the spaces, will result in a value of " when ".

Embedded boundary characters are not supported.web_reg_save_paramresults in a simple search for the next occurrence after the most recent left boundary. For example, if you have defined the left boundary as the character `{` and the right boundary as the character `}', then with the following buffercissaved:

          {a{b{c}

The left and right boundaries have been located. Since embedded boundaries are not supported, the `}' is matched to the most recent `{` appearing just before thec. The ORD attribute is 1. There is only one matching instance.

Theweb_reg_save_paramfunction also supports array type parameters. When you specify ōRD=All, all the occurrences of the match are saved in an array. Each element of the array is represented by theParamName_index. In the following example, the parameter name isA:

web_reg_save_param("A", "LB/ic=<a href=", "RB=\'>", "Ord=All", LAST);

The first match is saved asA_1, the second match is saved asA_2, and so forth. You can retrieve the total number of matches by using the following term:ParamName_count. For example, to retrieve the total number of matches saved to the parameter array, use:

TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));

The following table indicates how to use the boundary parameters to save portions of the parameter string:

Portion of string to save to parameter
LB
RB
entire string
empty
empty
a string delimited by boundaries
boundary
boundary
the beginning of a string until the first right boundary
empty
boundary
the last left boundary until the end
boundary
empty

This function is supported for all Web scrīpts, and for WAP scrīpts running in HTTP or Wireless Session Protocol (WSP) replay mode.

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.
    • IgnoreRedirections: If "IgnoreRedirections=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 "IgnoreRedirections=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 moretext flags. This attribute is required. See theBoundary Argumentssection.
    • NOTFOUND:The handling option when a boundary is not found and an empty string is generated.
      "Notfound=error", the default value, causes an error to be raised when a boundary is not found.
      "Notfound=warning"("Notfound=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 scrīpt. The"warning"option is ideal if you want to see if the string was found, but you do not want the scrīpt to fail.
      Note: IfContinue on Erroris enabled for the scrīpt, then even when NOTFOUND is set to"error", the scrīpt 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 ofInstanceinstead ofORDis 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 moretext flags. This attribute is required. See theBoundary Argumentssection.
    • RelFrameID:The hierarchy level of the HTML page relative to the requested URL. The possible values areALLor a number. ClickRelFrameID Attributefor a detailed descrīption. This attribute is optional.
      Note: RelFrameID is not supported in GUI level scrīpts.
    • 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 areHeaders(Search only the headers),Body(search only body data, not headers),Noresource(search only the HTML body, excluding all headers and resources), orALL(search body , headers, and resources). The default value isALL. This attribute is optional.

TAG: Zee的生活

fishsky的个人空间 引用 删除 fishsky   /   2011-08-01 11:03:32
5
 

评分:0

我来说两句

我的栏目

日历

« 2024-05-14  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 159198
  • 日志数: 146
  • 图片数: 1
  • 建立时间: 2006-12-05
  • 更新时间: 2012-11-16

RSS订阅

Open Toolbar