web_reg_save_param_json

web_reg_save_param_json

The value of a JSON node in the server response is recorded using the web_reg_save_param_json function. This function is typically used when the server answer has a JSON format. By including the element name’s (node’s) path in the function’s query string, the necessary dynamic value can be easily obtained. The subsequent requests make use of the captured value.

Why does the function name look this way?

The web protocol (referred to as “web”) uses the ‘web_reg_save_param_json’ function. In order to obtain the dynamic data that has been formatted as JSON, this function registers a request (denoted by “reg” and “json” respectively). The dynamic value must then be saved in a parameter (indicated by “save_param” words) after the request has been registered. Consequently, it has the name “web_reg_save_param_json”.

To access the web_reg_save_param_json input box, use the navigation:

  • ‘Ctrl+Alt+B’ or ‘View -> Steps’ will be required. Toolbox
  • ‘web_reg_save_param_json’ should be typed into the search field. VuGen will display the content that matches.
  • The ‘web_reg_save_param_json’ function should be double-clicked. The following inputs will be available in the window:
web_reg_save_param_json

  Figure(1)

 ‘web_reg_save_param_json’ attributes:

  1. Parameter Name: Name of the correlation parameter to be used to store the dynamic value. This field must be filled out.
  2. QueryString: This attribute is required. The path of the value to save must be specified for this attribute.
  3. SelectAll: This attribute is optional. When SelectAll=Yes is specified, an array is created and contains all instances of the match. The ParamName_index identifies each element of the array and is used to record the dynamic value on a particular occurrence. It saves the first match as ParamName_1, the second match as ParamName_2, and so on.
  4. 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 running. When you want to check if the string was discovered but do not want the script to fail, the “warning” option is useful.

      Note: If the script’s “Continue on Error” option is enabled, the script will still run even if NOTFOUND is set to “ERROR,” even if an error message will be recorded in the Extended log file.
  5. Scope: The ‘Filters (SEARCH_FILTERS)’ option contains 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 search is the 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 is only cookies.
  6. Header Name (HeaderNames): 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.
  7. 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.
  8. Content Type (ContentType): When a response has a header with the defined ContentType, LoadRunner looks for the dynamic value in that response. The * wildcard can be used in the ContentType. This quality is optional.
  9. Frame ID (RelFrameID): This parameter is optional. The HTML page’s position in the hierarchy with respect to the requested URL. Both ‘All’ and a number are viable options.

    Note: RelFrameID is not supported by GUI-level scripts.
  10. Disregard Redirection (DisregardRedirections): This attribute has the default value of “No” and is optional. The inputs include
    • Check (Yes): When the ‘IgnoreRedirections=Yes’ setting is used, LoadRunner is told not to look for dynamic values in responses to redirected requests. The rerouted request can be recognized by its HTTP 3XX response code.
    • Uncheck (No): LoadRunner even looks for dynamic values in the rerouted request response.
Example: ‘web_reg_save_param_json’

If you want to capture ‘Bengali’ in the below JSON response:

{

   “Indo-European”: {

     “Indo-Iranian”: {

       “Iranian”: [

         “Persian”

       ],

       “Indic”: [

         “Assamese”,

         “Bengali”

       ]

     },

     “Baltic”: [

       “Latvian”,

       “Lithuanian”

     ],

     “Slavic”: {

       “East Slavic”: [

         “Russian”

       ],

“south slav”: [

           “Bulgarian”

         ]

       }

     }

}

web_reg_save_param_json(“ParamName=c_JSONValue”,”QueryString=$.Indo-European.Indo-Iranian.Indic[1]”,”Not found=warning”,”Select All=Yes”,SEARCH FILTERS,”Range=BODY”,”IgnoreRedirects=Yes”,”RelFrameID=1″,”RequestUrl=http://demoptsite.com”,              LAST);
Screenshot (226).png

                                                 Figure (2)

How should the script use the web_reg_save_param_json function?

  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) WebRegSaveParameter JSON -> (Double click) WebRegSaveParameter JSON -> A window titled “web_reg_save_param_json – Save data to a parameter” will appear. Enter the necessary information and then click “OK”.

                                              EITHER

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

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_regexp
  • web_reg_save_param_xpath
  • web_reg_save_param_ex
  • web_reg_save_attrib
Scroll to Top