web_reg_save_param_xpath is used to capture the value of an XML node in the server response. Mostly, web services have their responses in XML which can be easily captured by providing the XML element name (node) in the query string of the function. The server response of some of the HTML web requests contains the embedded XML which requires web_reg_save_param_xpath to capture the dynamic value.
Why the function name is like this?
The ‘web_reg_save_param_xpath’ function is used for web protocol (denoted by ‘web’). This function registers a request (denoted by ‘reg’) to find out the dynamic data in the response formatted as XML (denoted by ‘xpath’). After registering the request, the next task is to save the dynamic value in a parameter (represented by ‘save_param’ words). Hence it is named as ‘web_reg_save_param_xpath’.
Follow the navigation to open the web_reg_save_param input box:
- Press ‘Ctrl+Alt+B’ or View -> Steps Toolbox
- Type ‘web_reg_save_param_xpath’ in the search box. VuGen will show the matched content.
- Double-click on the ‘web_reg_save_param_xpath’ function. The window will appear with the following inputs:
Attributes of “web_reg_save_param_xpath”:
a. Parameter Name: The name of the correlation parameter to store the dynamic value. This is a mandatory field.
b. QueryString: This is a mandatory attribute. In this attribute, you have to provide the XPath of the value to save.
c. ReturnXML: This is an optional attribute with the default value ‘No’. If ReturnXML=Yes, the data returned in the parameter specified by ParamName includes the entire XML node at the specified XPath, including contained elements. If ReturnXML=No, only the value of the element that matches the query is returned.
d. DFEs: This is an optional attribute. It is a comma-separated list of Data Formats Extensions that are to be used before the required search operation is to be performed.
e. SelectAll: This is an optional attribute. When you specify SelectAll=Yes, all the occurrences of the match are saved in an array. Each element of the array is represented by the ParamName_index and used to capture dynamic value on a specific occurrence. The first match is saved as ParamName_1, the second match is saved as ParamName_2, and so forth.
f. Warn if text was not found (Default is Error) (NotFound): This is an optional attribute and has ‘Error’ as a default value. This option handles the situation when the defined boundary does not match and generates an empty string. It has the following input options:
- ERROR: This is a default value. When a boundary is not found then LoadRunner highlight it as an error in the log.
- WARNING: LoadRunner does not issue an error. If the boundary is not found, it sets the parameter count to 0 and continues executing the script. The “warning” option is good when you want to see whether the string was found or not, but do not want the script to fail.
Note: If ‘Continue on Error’ option is enabled for the script then even when NOTFOUND is set to ‘ERROR’; the script continues when the boundary is not found, but an error message is written to the Extended log file.
g. Scope: This attribute comes under the ‘Filters (SEARCH_FILTERS)’ option. This is also an optional attribute with the default value “All”. It specifies the scope of the search of dynamic value within the response. The input options are:
- 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.
h. Header Name (HeaderNames): To enable this attribute you need to select ‘Scope’ type as Headers. Here, you can provide a comma-separated list of HTTP response header names then LoadRunner will search the dynamic values only in the specified headers. This is an optional attribute.
i. RequestURL: The dynamic values will be searched only in the responses of specified requests. The URL can contain the * wildcard. It is specially used to correlate the value coming in the response of flex_amf_call.
j. Content Type (ContentType): LoadRunner searches the dynamic value in the responses with the specified ContentType header. The ContentType can contain the * wildcard. This is an optional attribute.
k. Frame ID (RelFrameID): This is an optional attribute. The hierarchy level of the HTML page relative to the requested URL. The possible values are ‘All’ or a number.
Note: GUI-level scripts do not support RelFrameID.
l. Ignore Redirection (IgnoreRedirections): This is an optional attribute with the default value “No”. The inputs are:
- Check (Yes): By setting the ‘IgnoreRedirections=Yes’, it instructs LoadRunner not to search the dynamic value in the response of the redirected request. You can identify the redirected request by its response code HTTP 3XX.
- Uncheck (No): LoadRunner even searches the existence of dynamic value in the response of the redirected request.
Example: ‘web_reg_save_param_xpath’ with all attributes
<abc_college>
<course>
<student>
<name>Performnace Tester</name>
<rollno>001</rollno>
</student>
</course>
<course>
<student>
<name>Performance Engineer</name>
<rollno>002</rollno>
</student>
</course>
</abc_college>
web_reg_save_param_xpath(
"ParamName=c_StudentName",
"QueryString=/abc_college/course/student/name",
"ReturnXml=No",
"NotFound=warning",
"SelectAll=Yes",
SEARCH_FILTERS,
"Scope=BODY",
"IgnoreRedirections=Yes",
"RelFrameID=1",
"RequestUrl=http://dummypt.com/",
LAST);
How to use the web_reg_save_param_xpath function in the script?
- Identify the dynamic value in the script (How?)
- Locate the cursor before the request which has the dynamic value in the response.
- Right click -> Insert -> New Step -> Steps Toolbox -> (Search for keyword) web_reg_save_param_xpath -> (Double Click on) web_reg_save_param_xpath -> ‘Save Data to a Parameter’ window will open -> Provide the required input and press Ok.
OR
If you know the correct syntax and attributes of the web_reg_save_param_xpath function then you can simply type in the script.
Important Point: LoadRunner’s correlation functions are always written/placed before the request whose response contains the dynamic value.
In addition, there are four more correlation functions in the LoadRunner. Refer to the link to get more details:
- web_reg_save_param
- web_reg_save_param_regexp
- web_reg_save_param_ex
- web_reg_save_param_json
- web_reg_save_attrib