The usage and difference of loadrunner--web_find and Web_reg_find

Source: Internet
Author: User
Tags define find

one, Web_find () functionThe function is to "find the appropriate content in the page", the common parameters and meanings are as follows:

Web_find ("Web_find",//define the name of the lookup function "Rightof=a",//define the right edge of the find character
"Leftof=b",//define the left bounds of the find character
"What=name",//define what to look for
last);
Use this function to note the following: 1. LocationThis function is found in the page after the page content is displayed, so it can only be written after the content is being searched. 2. Recording ModeThis function can only be found in scripts based on HTML-mode recording
3. Content checking options must be enabled
In runtime setting->preferences, select the Enable image and text check, otherwise do not perform the lookup function 4. This function is not supported in VB and JAVA syntax
The function has one of the following disadvantages 1, the execution is less efficient 2, do not return the results of the search, if you want to perform this function after the search results for further action, there is no return value can be based on for example: find "Login succeeded" string in the page, if the string found in the LogIn the output "login success", if the string is not found, then output "Login failed" in the log, at this time using the function is not based on this judgment, but using the Web_reg_find () function, using it savecount can be judged, the specific method we introduce below. Second, Web_reg_find () functionThe function is to "find the appropriate content in the cache", the common parameters and meanings are as follows:
Web_reg_find ("Search=body",//Definition lookup range
"SAVECOUNT=DDD",//define Lookup Count variable name "TEXT=AAAA",//define Find content
last); Use this function to note the following: 1. LocationThis function is written before the request to find the content, usually written before the following six functions:
Web_castom_request ();
Web_image (); Web_link (); Web_submit_data (); Web_submit_form (); Web_url ()
2, the use of skills
There is a "savecount" in the parameter of the function, which can record the number of occurrences of finding content in the cache, which we can use to determine if the content to find is found, as an example to illustrate: (Example of a reference to LR's help)//Run the WebTours 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 logs 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) {//To determine if Welcome string occurrences are greater than 0
Lr_output_message ("Log on successful."); }//output Log on successfulelse{//If the number of occurrences is less than or equal to Lr_error_message ("Log on Failed"),//Log on Failedreturn (0) is output in the logs;
}
I think this method is very useful, we can extrapolate and apply it to our actual project. iii. methods of inserting functions1. Hand write, write the function manually at the location where the function needs to be inserted
2. Hover the cursor at the location where you want to insert the function, in the Insert menu, select New Step, select or find the function you want to insert in the list, fill in the necessary parameter 3 as prompted, in the tree view mode, select the location where you want to insert the function, right-click the insert After or insert before, fill in the necessary parameters as prompted Iv. steps to insert

1. Switch the script to the tree structure, find the text content of your check on page view, and execute the mouse message and select Copy selection.

2. Switch the script back to the Code interface, and add the following code to the uplink of the cursor blinking:

Note: The cursor blinks upward: If the cursor blinks on line 10th, the cursor blinks on the uplink to line 9th.

The code you add is different depending on how you check it, and you can choose one of them.

Code One:

Web_reg_find ("Text=payment Details", last);

Code ideas:

1. "Payment Details" is the text you want to check;

2. The script executes here, if the string is found on the page, the script continues to execute, if not found, the script will error and end.

Code two:

Web_reg_find ("Text=payment Details", "Savecount=para_count", last); function of Check

Web_submit_form ("reservations.pl_2",//code for the recording of the page to check

"Snapshot=t22.inf",

ItemData,

"Name=outboundflight", "value=003;0;06/23/2007", Enditem,

"Name=reserveflights.x", "value=61", Enditem,

"Name=reserveflights.y", "value=2", Enditem,

last);

if (Atoi (lr_eval_string ("{para_count}") >0)//Verify that the string to be checked on the page is found

Lr_output_message ("We find the string!");

Else

Lr_output_message ("Sorry,don ' t find the string!");

Code ideas:

1. "Payment Details" is the text you want to check;

2. The script executes here, regardless of whether there is a string on the page you want to check, the script will not error, but the execution goes on.

3. This code will find the number of strings you want to check and save as a parameter. Then, after the page code, check if the value of this parameter is greater than 0 to determine if the string you want to check is found.

Code Three:

A. Web_reg_find ("Text=payment detdils", "Fail=notfound", last);

B. Web_reg_find ("Text=payment detdils", "Fail=found", last);

Code ideas:

1. "Payment Details" is the text you want to check;

2. If the A code: script execution here, if the check string is not found, the script will fail, and stop execution. Instead, it continues.

3. B Code: The script executes here, if a check string is found, the script will fail and stop execution. Instead, it continues.


v. Summary
1, these two function function type is different, web_find is the ordinary function, Web_reg_find is the registration function 2, Web_find must turn on the Content Check option when using, but Web_reg_find does not have this limit 3, web_ Find can only be used in scripts based on HTML-mode recording, and Web_reg_find does not have this restriction 4, Web_find is in the returned page to do the content lookup, Web_reg_find is in the cache to find 5, web_find in the execution efficiency is inferior web_ Reg_find plainly, with Web_reg_find priority is much higher than web_find, so web_find already belongs to backward compatible features, not recommended to use.

The usage and difference of loadrunner--web_find and Web_reg_find

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.