web_reg_save_param_regexp

One of the simplest ways to create the correlation logic for managing dynamic values in the script is through the use of regular expressions in LoadRunner. The web_reg_save_param_regex method makes use of regular expression tokens to capture dynamic values in the response. Over web_reg_save_param, the key benefit of web_reg_save_param_regexp is the ability to escape the content (string) in order to capture the desired value. See the example provided later in this essay. The best choice for you is web_reg_save_param_regexp if you have experience writing regular expressions.

Why does the function name look this way?

It uses the web_reg_save_param_regexp function, which is referred to as “web.” In order to determine the dynamic value based on the regular expression, this function registers a request (denoted by the letter “reg”). The next step after registering the request is to save the dynamic value in a parameter (designated by the words “save_param”). Consequently, it has the name “web_reg_save_param_regexp”.

To access the web_reg_save_param_regexp input box, use the navigation:

  1. ‘Ctrl + Alt + B’ or ‘View -> Steps Toolbox’ should be pressed.
  2. ‘web_reg_save_param_regexp’ should be typed into the search box. You will see the matched content from VuGen.
  3. To use the ‘web_reg_save_param_regexp’ function, double-click it. The following inputs will be available in the window:
web_reg_save_param_regexp function in LoadRunner

                 Figure(1)

‘web_reg_save_param_regexp’ has the following characteristics:

  1. Parameter Name: Name of the correlation parameter, which saves the dynamic value, in item a. This field must be filled out.
  2. RegExp: This attribute is required. You must create a regular expression for this attribute in order to collect dynamic data. To learn how to write a regular expression, refer to the post.
  3. Group: This attribute is optional. Multiple dynamic values can be captured with a single regular expression when using group attributes. If you enter the value 0 (zero), the full expression together with the entered text is saved. The top number is 10. Example: If you need to capture SurName and you have set the regular expression as shown below, Group will be 2.

    RegExp=Name=(.*?) and SurName=(.*?)”,

  4. DFEs: This attribute is optional. It is a list of Data Formats Extensions that should be used prior to doing the necessary search operation, each entry separated by a comma.
  5. Ordinal (ORD): This attribute is optional. It’s used to record dynamic values for a particular occurrence. All occurrences of the matched boundary are recorded in an array if you specify the value of Ordinal (ORD) = ALL. The ParamName_index identifies each element of the array individually. The parameter name in the example below is c_custID:

    web_reg_save_param_regexp(

    “ParamName=c_custID”,

    “RegExp=customerID=(.*?);”,

    “NotFound=warning”,

    “Group=2”,

    “Ordinal=ALL”,

    LAST);


    The c_custID_1 value is saved for the first match, the c_custID_2 value for the second match, and so on. Using the ParamName_count argument, you may get the total number of matches. For instance, you can use the following sentence to retrieve the total number of matches saved to the parameter array:

    customerCount=atoi(lr_eval_string(“{c_custID_count}”));

  6. f.Warn if the text could not be located (Error by default) (NotFound): ‘Error’ is the default value for this optional parameter. When the defined boundary does not match, this option responds by producing an empty string. The following input methods are available:
    • ERROR: This default setting. When a boundary cannot be located, LoadRunner flags the issue as an error.
    • A warning is not issued by LoadRunner: If the boundary cannot be located, the parameter count is set to 0 and the script is still being run. When you want to know whether the string was discovered or not but do not want the script to fail, the ‘warning’ option is useful.
  7. Scope: The ‘Filters (SEARCH_FILTERS)’ option has this attribute. This attribute similarly has a default value of “All” and is optional. It details the parameters of the response’s search for dynamic value. Options for input include:
    • All: The scope of the search is body, headers, and resources 
    • Headers: It indicates to search only in the headers
    • Body: The scope of the search is only body, not headers
    • Cookies: The scope of the search only cookies.
  8. The Header Name (HeaderNames) is: You must choose the ‘Scope’ type as Headers in order to enable this feature. You can enter a list of HTTP response header names separated by commas in this field, and LoadRunner will only look for dynamic values in the headers you specify. This quality is optional.
  9. RequestURL: Only the replies to the given requests will be examined for dynamic values. The * wildcard is acceptable in URLs. It is specifically used to correlate the value that appears in the flex_amf_call response.
  10. Content Type (ContentType): When a response has a header with the specified ContentType value, LoadRunner looks for that dynamic value. The wildcard character * can be used in ContentType. This quality is optional.
  11. Frame ID (RelFrameID): This parameter is optional. The position of the HTML page in the hierarchy relative to the requested URL. Both ‘All’ and some are viable options.
    • Check (Yes) – When using the ‘IgnoreRedirections=Yes’ setting, this tells LoadRunner not to look for dynamic values in responses to redirected requests. The redirected request can be recognized by the 3XX HTTP response code.
    • Uncheck (No): LoadRunner even looks for dynamic values in the redirected request response.

‘web_reg_save_param_ex’ is an example. with qualities

web_reg_save_param_regexpFigure (2)

web_reg_save_param_regexp(

“ParamName=c_custInfo”,

“RegExp=Name=(.*?) and Surname=(.*?)”,

“Not found=warning”,

“group=2”,

“ordinals=ALL”,

SEARCH FILTERS,

“Range=BODY”,

“IgnoreRedirects=Yes”,

“RelFrameID=2”,

“RequestUrl=http://myperformancetetsingdemosite.com”,

LAST);

How does the script’s web_reg_save_param_regexp function work?

  1. Determine the dynamic value of the script (how?)
  2. Look for the requested cursor so that you can see the dynamic value of the response.
  3. Insert with a right click. New Action -> Step Tools -> (Enter a keyword) WebRegSave Parameter Regexp (Two Clicks) WebRegSave Parameter Regexp A dialog titled “web_reg_save_regexp – Save Data to a Parameter” appears. Enter the necessary information and then click “OK”.

EITHER

You can write the script quickly if you are familiar with the features of the web_reg_save_param_regexp function and the correct syntax.

Important Note: Mapping functions written or published by LoadRunner always precede requests whose responses contain dynamic values.

LoadRunner also has four additional mapping functions. Click on the following link for more information:

  • web_reg_save_param
  • web_reg_save_param_ex
  • web_reg_save_param_xpath
  • web_reg_save_param_json web_reg_save_attrib

Commonly used regular expression tokens:

  • (.*?) – Matches any string, even the one that starts a new line
  • (.+?) – Matches strings that contain letters, numbers, and spaces, but no new lines.
  • ([a-zA-Z]+) – Accepts characters in the range a-z or A-Z
  • ([d]) OR ([0-9]+). – Matches any decimal digit

How to capture the correct value while escaping the response content?

Example: A response to a request contains the following information: class, type, category, food category, and name.

class=alive,type=mammal,category=animal,foodcategory=carnivores,name=lion;

class=alive,type=mammal,category=animal,foodcategory=carnivores,name=tiger;

class=alive,type=mammal,category=animal,foodcategory=carnivores,name=leopard;

class=alive,type=mammal,category=animal,foodcategory=carnivores,name=dog;

class=living being,type=reptile,category=animal,foodcategory=carnivores,name=snake;

class=living,type=reptile,category=animal,foodcategory=carnivores,name=lizards;

class=alive,type=mammal,category=animal,foodcategory=carnivores,name=cat;

If you wanted to list the name of each mammal, you would probably write something like this:

class=living being,type=mammal,category=animal,foodcategory=carnivores,name=([a-z]+);

You can summarize the token string as follows by using an escape token:

class=alive,type=mammal.*?name=([a-z]+);

Scroll to Top