There are two types of checkpoints in LR: Pictures and text.
Common checkpoint functions are as follows:
1) the Web_find () function is used to search for the specified text string from an HTML page;
2) the Web_reg_find () function registers a request to search for the specified text string on the HTML Web page retrieved by the next operation function (such as web_url);
3) the Web_image_check () function is used to find the specified picture from an HTML page;
4) Web_global_verfication () belongs to the registration function, registering a request to search for a text string in a Web page, with Web_reg_ Find only performs a search in the next action function, except that it executes the search for the specified text string in all subsequent action class functions;
The following sections describe the use of the above functions:
1, Web_find () function parameter example:
Web_find ("Web_find", "Righof=a", "Leftof=b", "What=name", last);
Parameter explanation: "Web_find" defines the name of the lookup function; "Leftof" and "righof=" are used to define the left and right bounds of the lookup character; "what=" defines the search;
For example, the above parameter means to find the left boundary is B, the right border is a, the content is the name of the information;
Use this function to note that the function is to find the contents of the page, so it should be placed after the content you want to find, the function can only be found in the script based on the HTML mode recording
Caveats: When you use this function, you change the settings under Vuser->run-tme settings
Tick enable Image and text check
The system does not check this option by default.
2, Web_reg_find () function parameter example:
Web_reg_find ("Search=body", "savecount=ddd", "test=aaa", last);
Parameter interpretation: Search is used to define the look-up scope, Savecount defines the lookup count variable name, which can record the number of occurrences of the lookup in the cache, which can be used to determine if the content to find is found;
For example, in the example above the meaning is the body in the search for information of AAA, and the number of occurrences recorded in the variable ddd;
"Code One: Web_reg_find (" Text=payment Details ", last);
Code ideas: 1. " Payment Details "For 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 "For 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. On the contrary, it has been executed. "
Use this function to note: The function is to find the appropriate content in the cache, so it should be placed before the search, usually written before the following six functions: Web_castom_request (); Web_image (); Web_link (); Web_submit_data (); Web_submit_form (); Web_url ();
Tip: 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 illustrated below: (example of a reference to LR's help)
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 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 successful
else{//If the number of occurrences is less than or equal
Lr_error_message ("Log on Failed"); Output log on failed in logs
return (0); }
I think this method is very useful, we can extrapolate, apply to our actual project
Note: The checkpoint added during recording is Web_reg_find () and the parameter is only "text="
3, Web_image_check () function parameter description:
Web_image_check ("Web_image_check", "alt=", "src=", last);
Parameter explanation: The values of "Alt" and "SRC" are taken directly from the corresponding parameters of the image in the source code of the Web page;
Note: When using this function, to check the Enable Image and text check in Vuser->run-tme settings, see the Considerations in Web_find ().
After testing, the function is used to find the contents of the front or back, does not affect the search results.
Illustration (script)
The script logs the operation to exit after logging into the system, in the script with the Atoi () function and the lr_eval_string ("{Savecount defined variables}") Two functions together to determine whether the number of occurrences of the search is greater than 0, if greater than 0, enter the login success information.
Vuser_init ()
{
Web_url ("Xjcost",
"Url=http://gczj-server8:9205/xjcost/",
"Resource=0",
"Reccontenttype=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=html",
Extrares,
"Url=jsp/images/index/index.swf", Enditem,
"Url=jsp/images/index/xxfb2.gif", Enditem,
"Url=jsp/images/index/ywpt2.gif", Enditem,
last);
Web_url ("Useraction.struts",
"Url=http://gczj-server8:9205/xjcost/useraction.struts?actiontype=relogin",
"Resource=0",
"Reccontenttype=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=html",
last);
return 0;
}
Action ()
{
Lr_start_transaction ("log_on");
Lr_rendezvous ("log_on");
Web_add_cookie ("useraccount=admin; Domain=gczj-server8 ");
Web_reg_find ("text= Welcomes You",
"Savecount= welcome you _count",
last);
Web_image_check ("Web_image_check",
"Src=/xjcost/jsp/images/index1/edit_01.gif",
last);
Web_submit_data ("Userlogin.struts",
"Action=http://gczj-server8:9205/xjcost/userlogin.struts?actiontype=userlogin",
"Method=post",
"Reccontenttype=text/html",
"Referer=http://gczj-server8:9205/xjcost/useraction.struts?actiontype=relogin",
"Snapshot=t3.inf",
"Mode=html",
ItemData,
"Name=useraccount", "Value=admin", Enditem,
"Name=pwd", "value=1111", Enditem,
Extrares,
"Url=jsp/images/index1/edit_01a.gif", "referer=http://gczj-server8:9205/xjcost/userlogin.struts?actiontype= Userlogin ", Enditem,
last);
Web_find ("Web_find",
"Welcome to What=",
last);
Lr_end_transaction ("log_on", Lr_auto);
Check if login is successful
If the "welcome you" character appears more than 0, output "Log on successfully!"
if (Atoi (lr_eval_string ("{Welcome you _count}") >0)
Lr_output_message ("Log on successfully!");
Else
Lr_error_message ("Log on failed!");
return 0;
return 0;
}
The function of the atoi () function is to convert an ASCII string to an integral type
The lr_eval_string () function is to get the parameter value, replace the parameter value in the string variable with the current parameter value, and return the string
Vuser_end ()
{
Lr_think_time (4);
Web_url ("Useraction.struts_2",
"Url=http://gczj-server8:9205/xjcost/useraction.struts?actiontype=relogin",
"Resource=0",
"Reccontenttype=text/html",
"Referer=",
"Snapshot=t4.inf",
"Mode=html",
last);
return 0;
}
Global.h:
#ifndef _globals_h
#define _globals_h
//--------------------------------------------------------------------
Include Files
#include "Lrun.h"
#include "web_api.h"
#include "Lrw_custom_body.h"
//--------------------------------------------------------------------
Global Variables
#endif//_globals_h
Replay Log Common Information description
1. Log information for the Web_find () and Web_image_check () functions (these two log messages are actually the same, except that the function names and parameters of the output are different)
1) Information 1ACTION.C: verification checks not enabled. Web_image_check is skipped. See the ' Run-time settings/preferences/checks '
[msgid:mmsg-27197]
ACTION.C (+): Web_image_check was successful
[msgid:mmsg-26392]
This message appears stating that the Enable Image and text check are not checked
2) Information 2action.c: "Web_image_check" succeeded (1 occurrence (s) found. Alt= "", src= "/xjcost/jsp/images/index1/edit_01.gif")
[msgid:mmsg-27192]
ACTION.C (+): Web_image_check was successful
[msgid:mmsg-26392]
This message appears stating that the checkpoint setting was successful and that the information was found
3) Information 3action.c: Error-27191: "Web_image_check" failed (0 occurrence (s) found. Alt= "", src= "/xjcost/jsp/images/index1/edit_1.gif")
[msgid:merr-27191]
ACTION.C: Web_image_check Highest severity level was "ERROR"
[msgid:mmsg-26391]
This message appears, indicating that the content you are looking for is not found. Then, try the following actions in turn:
(1) Check the parameters of the information is wrong;
(2) If it is Web_find (), check if the position of the function is after the content to be searched;
(3) If it is Web_image_check (), look at the source code of the image, to see if it is a picture on this page, it is likely that the image selection error, that the selected picture does not belong to the page.
2. Log information for the Web_reg_find () function
1) Information 1action.c (): Registering Web_reg_find was successful
[msgid:mmsg-26390]
The message appears, indicating that the content was found
2) Information 2action.c: Error-26366: "TEXT=ABC" not found for Web_reg_find
[msgid:merr-26366]
ACTION.C: Web_submit_data ("userlogin.struts") highest severity level was "ERROR", 18364 body bytes, 918 header bytes, Chunking Overhead bytes
[msgid:mmsg-26387]
This information is displayed in red on the Replay log page, stating that no content was found, and this situation attempts the following two actions:
(1) The information of the parameter is correct;
(2) See if the function is in front of the found content.
Ways to insert a function:
1, manual writing, in the need to insert the function of the location of the manual write the function;
2. Hover the cursor where you want to insert the function, and in the Insert menu, select New Step, select or find the function you want to insert in the list, and fill in the necessary parameters as prompted;
3. In the tree view mode, select the location of the function to insert in the Trees menu, right-click, choose Insert After or insert before, fill in the necessary parameters according to the prompt;
Summarize:
1, these two function function type is different, web_find is the common function, the 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, while Web_reg_find does not have this limitation;
4, Web_find is in the return of the page to find content, Web_reg_find is in the cache to find;
5, Web_find in the implementation efficiency is inferior to web_reg_find;
LoadRunner Checkpoint Usage Summary