1

While going through the posts ,it mentioned like " web_reg_find() will execute successfully every single time even if it does not find the value."

Here is the post URL

general trend in responstime indicating? https://stackoverflow.com/a/15008513

I am using URL mode for recording my application. Do we need to write some code to confirm the text check performed by web_reg_find() OR not required?

Regards.

Community
  • 1
  • 1
Guru
  • 433
  • 6
  • 14

3 Answers3

0

Please make sure you put web_reg_find just above the request from which you need to find.

something like this:

web_reg_find("Text=Welcome to the Web Tours site", "Search=Body", LAST);

web_url("WebTours", "URL=...", ...);

  • Hi Mohnish,In the post i refered it is mentioned like "web_reg_find() context is the next call. With HTML mode that call made include subcalls. You need to be very careful on placement of web_reg_*() calls in URL mode to ensure that you have the proper context. And yes, web_reg_find() will execute successfully every single time even if it does not find the value" Could you please explain me this. – Guru Oct 29 '14 at 07:38
0

As per the example 2 given in HP LoadRunner Function Reference, its better to include Text Check Validation. Please see below.

Example 2 is the same as example 1, but because Save Count is used, the script execution is not halted on failure. Instead, the error is handled in the code.

// Run the Web Tours sample 

web_url("MercuryWebTours",

    "URL=http://localhost/MercuryWebTours/",

    "Resource=0",

    "RecContentType=text/html",

    "Referer=",

    "Snapshot=t1.inf",

    "Mode=HTML",

    LAST );

// Set up check for successful login by looking for "Welcome"

web_reg_find("Text=Welcome",

    "SaveCount=Welcome_Count",

    LAST );

// Now log in

web_submit_form("login.pl",

    "Snapshot=t2.inf",

    ITEMDATA,

    "Name=username", "Value=jojo", ENDITEM,

    "Name=password", "Value=bean", ENDITEM,

    "Name=login.x", "Value=35", ENDITEM,

    "Name=login.y", "Value=14", ENDITEM,

    LAST );

// Check result

if (atoi(lr_eval_string("{Welcome_Count}")) > 0){

    lr_output_message("Log on successful.");

    }

 else{

     lr_error_message("Log on failed");

     return(0);

 }

- Hope this helps.

Dinesh
  • 1
  • 2
0

web_reg_find is a service function. So, even if the value itself is not found the execution of the service function is successful. So, yes, you do need to check your variable used to collect the number of instances of the string for a successful non-zero count find.

Yes, context is next request.

James Pulley
  • 5,606
  • 1
  • 14
  • 14
  • Hi James,Thanks for the response.When i did not check for non-zero count also, if the specified text is not found the script will stop and throw an error.Could you please explain further – Guru Nov 05 '14 at 04:53
  • That is certainly one method to cause a script to halt, but it is not the preferred way. You should elegantly exit the iteration rather than have it cut midstream. Check continue on error. check for the number of instances and then branch your code to gracefully exit the iteration if your searched term is not found – James Pulley Nov 05 '14 at 14:26