web_reg_find

web_reg_find is a LoadRunner function which is used as a content check function in the test script.

  • This function helps to verify whether or not the page you received is the desired page by searching for an expected text string. 
  • The return value of web_reg_find indicates only if the registration succeeded and not if the check succeeded.
  • You can search the text either by defining the specific text or by defining the boundaries of the text (like Correlation). 
  • You can not specify both text and a prefix-suffix pair.
  • This function can be used for both HTML and URL-based scripts.

Why the function name is like this?

web_reg_find function is used for web protocol (denoted by ‘web’). This function registers a request to search for a text string (denoted by ‘reg’). After registering the request, the next task is to find and validate the text string on the web page retrieved by the next action function (represented by the ‘find’ word). Hence it is named as ‘web_reg_find’.

How to add the web_reg_find function in the script?

During Recording:

1. While recording the script, select the text that you want to use as a text check on the web page.

2. Click the ‘Insert Text Check’ button on the VuGen floating bar.

LoadRunner Floating Bar
Figure 01: ‘Insert Text Check’ option on the floating bar

3. web_reg_find() function containing selected text, will be added in the script. VuGen always inserts the text check function (i.e. web_reg_find) before the web page request has the selected text. The placement for the text check function in the script is as same as the correction functions.

Post Recording:

1. Locate the cursor before the transaction of a page request on which you want to apply content check.

2. Go to Menu then select View -> Steps Toolbox (or Press Ctrl+Alt+B) to open the Steps Toolbox.

3. In the Steps Toolbox, type ‘web_reg_find’

4. The search result will show you the ‘web_reg_find’ function. Double-click on it.

5. Enter the value in the ‘Find Text’ input box. Refer to the attribute section below in this post to understand what are the inputs you need to provide in the dialogue box.

6. Click the ‘OK’ button.

web_reg_find input box
Figure 02: ‘Find Text’ input box

Attributes of ‘web_reg_find’:

There are two search options available in the ‘Find Text’. You choose either of them as per the type of the text i.e. Text String or Text Boundary.

a. Search for specific Text: If the search string is specified then you can use this option. Example: Welcome, Payment Details, Customer Form etc. You can further customize your search by using text flags like match case, binary data, use # for any digit, use wild card etc.

b. Search for Text by start and end of string: This option is used when the string is not known in advance, but you know what strings will precede and follow it. For example, when a user places an order and server returns a text string along with the order number like this “Your order number is <order_number>. Thank you!” The order number is always unique for all the users who successfully placed the order. To confirm that the order has been placed, it is sufficient to confirm that there is some string preceded by “Your order number is ” and followed by “. Thank you!”.

Hence Start String would have “Your order number is” and the End String would have . Thank you!”  

You can further customize your search by using text flags like match case, binary data, use # for any digit, use wild card etc.

c. Search in (Search): This is an optional attribute with the default value ‘All’. The scope of the search is to search for the delimited data. The possible values 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

d. SaveCount: The name of the variable that will store the number of matches that were found in the response (or web page). This attribute is used for two purposes. First, to verify whether the string is found or not and secondly if found then how many times? You can use the SaveCount parameter to pass/fail the transaction using if condition. See the below example from the mercury site:

web_reg_find example

e. Fail if: This is an optional attribute and the default value is “Notfound”. It has two options; NotFound and Found. You can choose either of the options as per your requirements.

  • Notfound indicates that an error occurs when the text is not found. You use NotFound when searching for the text you expect to find if the Web request succeeds. Example: Title of the page, Your Order Number etc.
  • Found indicates that the check fails when the text is found. Example: Searching for the word ‘500/Internal Server Error’ or only ‘Error’ etc.

Note: If both SaveCount and Fail are used, the Fail handling option specified works together with the SaveCount. Thus, if SaveCount is used with “Fail=NotFound” and the text is found, the SaveCount parameter is assigned the number of occurrences and the check succeeds. If the text is not found, the SaveCount parameter is assigned “0” and the check fails. Of course, if the text is not found and “Fail=NotFound” has been specified, the value “0” of the parameter is only useful if the run–time setting Continue on error is selected.


You may be interested:


Leave a Comment