loadrunner common check function

web_find --- search for text strings in html page

int  web_find( const char * StepName, < Attributes and Specifications list>, char * searchstring, LAST ); 
 
StepName: Step name Required
Attributes and Specifications list: the list of attributes, optional
    expect: the definition of a successful return to the standard, found (the default) - Indicates the string returned to find success, notfound- returns a string that represents not found success
    Matchcase: case-sensitivity, yes- express case-sensitive, no (default) - Indicates not case sensitive
    report: definition of the content of the reported results, success- contains only success, failure- contains only fail, always (default) - contains all
    onfailure = abort: terminate the script fails
    RightOf: From the right side of the specified string Find
    LeftOf: From left to start looking specified string
 
Runtime Settings ->Preferences->Checks   勾选Enable Image and text check
A script:

The Action ()
{
web_custom_request ( "baidu_request",
"the URL = HTTP: //www.guanggoo.com/t/48529#reply3",
"= the GET Method,",
"the TargetFrame =",
"the Resource = 0",
"the Referer = ",
" Body = ",
LAST);

web_find (" web_find ",
// expected to return a successful result is to find a string, because the current page that contains the string you want to find, so the result is success
" found the expect = ",
/ / current page in the search string "sayno"
"= sayno the What",
LAST);

web_find ( "web_find",
// expected to return a successful result is to find a string, because the current page that contains the string you want to find, it returns the result success is
"the Expect = found",
// the current page in the search string "sayyes"
"= sayyes the What",
LAST);
return 0;
}

operation result:

Action.c(12): "web_find" successful. 2 occurrence(s) of "sayno" found (RightOf="", LeftOf="") [MsgId: MMSG-27196]
Action.c(12): web_find was successful [MsgId: MMSG-26392]
Action.c(19): web_find started [MsgId: MMSG-26355]
Action.c(19): Error -27195: "web_find" failed. 0 occurrence(s) of "sayyes" found (RightOf="", LeftOf="") [MsgId: MERR-27195]
Action.c(19): web_find highest severity level was "ERROR" [MsgId: MMSG-26391]

 

--- web_reg_find registration function, search for a text string in the following request

The action function is "lookup in the cache corresponding content", and the meaning of the following common parameters:
web_reg_find ( "Body Search =" // definition of the Look
"SaveCount = ddd", // Find the definition count variable name
"Text = aaaa", // Find the definition content
LAST);
Using this function note the following:
 
1, location
 
This function is written before're looking for content requests, usually written before the six functions as follows:
Web_castom_request ();
web_image ();
web_link();
web_submit_data();
web_submit_form();
web_url ()
2, using techniques
there is a "SaveCount" parameter of the function, the parameters can record the number of lookups content that appears in the cache, we can use this value to determine whether or not what you're looking to be found, following give :( cited an example to illustrate examples to help in LR)
 
// Run theWebTours 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);
The Check Result //
IF (atoi (lr_eval_string ( "Welcome_Count {}"))> 0) {// if the number is determined Welcome string appears greater than 0
lr_output_message ( "Log ON successful.");} // log output Log on successful
else {// if the number of occurrences or less
lr_error_message ( "Log on failed"); // in output Log on failed log
return (0);
}
I think this is useful, we can learn by analogy, applied to our actual projects
Third, the method of inserting function
 
1, hand-written, the need to insert a function of position of the hand-written function

2, the cursor To insert a function of position in the INSERT menu, select the new step, select or lookup function to be inserted in the list, follow the prompts to fill in the necessary parameters
3, in the tree view mode, select the function you want to insert the location, right in the tree menu, select the insert after or insert before, follow the prompts to fill in the necessary parameters
IV Summary
1, these two functions different function types, WEB_FIND is a normal function, WEB_REG_FIND are registered function
 
2, you must check the option to open the content WEB_FIND use, but is not no such restriction WEB_REG_FIND
 
3, WEB_FIND script can only be used only in HTML-based recording mode, whereas no such restriction WEB_REG_FIND
4, WEB_FIND is to find the content in the page returned, WEB_REG_FIND is to find in the cache
 
5, WEB_FIND inferior in efficiency WEB_REG_FIND

Guess you like

Origin www.cnblogs.com/youyouyunduo/p/11829170.html