web_reg_save_param_xpath
To record the value of an XML node in the server response, use web_reg_save_param_xpath. Most web services return XML as their response format, making it simple to capture these responses by including the name of the XML element (or “node”) in the query string of the function. Some HTML web requests have embedded XML in the server response, which necessitates the use of web_reg_save_param_xpath in order to capture the dynamic value.
Why does the function name look this way?
The function ‘web_reg_save_param_xpath’ is used for the web protocol, which is indicated by ‘web’. This function registers a request (denoted by ‘reg’) to discover the dynamic data in the response represented as XML (denoted by ‘XPath’). The task of saving the dynamic value in a parameter (expressed by the words ‘save_param’) follows registering the request. Consequently, it has the name “web_reg_save_param_xpath”.
To access the web_reg_save_param input box, use the navigation:
- ‘Ctrl+Alt+B’ or ‘View -> Steps’ will be required. Toolbox
- ‘web_reg_save_param_xpath’ should be typed into the search box. VuGen will display the content that matches.
- The ‘web_reg_save_param_xpath’ function should be double-clicked. The following inputs will be available in the window:
“web_reg_save_param_xpath” characteristics include:
- Parameter Name: Name of the correlation parameter to be used to store the dynamic value. This field must be filled out.
- QueryString: This attribute is required. You need to enter the XPath of the value you want to preserve in this attribute.
- ReturnXML: is an optional attribute with the value “No” by default. If ReturnXML=Yes, the complete XML node at the given XPath, including enclosed elements, is returned in the parameter defined by ParamName. Only the value of the element that matches the query is returned if ReturnXML=No.
- 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.
- 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 of a particular occurrence. It saves the first match as ParamName_1, the second match as ParamName_2, and so on.
- 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 check if the string was discovered but do not want the script to fail, the “warning” option is useful.
- 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.
- Header names: 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.
- 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.
- Content Type (ContentType): When a response has a header with the provided ContentType, LoadRunner looks for the dynamic value in that response. The * wildcard can be used in the ContentType. This quality is optional.
- 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 that RelFrameID is not supported by GUI-level scripts. - Ignore Redirection (IgnoreRedirections): This optional property has the default value of “No”. 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.
‘web_reg_save_param_xpath’ as an example, with all properties
<abc_college> <coursesmy> <student> <name>Performance 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”,
“Not found=warning”,
“Select All=Yes”,
SEARCH FILTERS,
“Range=BODY”,
“IgnoreRedirects=Yes”,
“RelFrameID=1”,
“RequestUrl=http://dummypt.com/”,
LAST);
How does the script’s web_reg_save_param_xpath function work?
- Determine the dynamic value of the script (how?)
- Look for the requested cursor so that you can see the dynamic value of the response.
- Right-click and select ‘Insert’, ‘New Step’, Step Tools -> Web_reg_save_param_xpath (Search Keyword) -> (Double-click) web_reg_save_param_xpath A dialog titled ‘Save data to a parameter’ will appear. Enter the necessary information and then click “OK”.
EITHER
You can easily write the script if you are familiar with the correct syntax and attributes of the web_reg_save_param_xpath 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_ex
- web_reg_save_param_json
- web_reg_save_attrib