文本检查点web_reg_find和web_find两个函数的区别

LR脚本实战:文本检查点web_reg_find和web_find两个函数的区别

 
web_reg_find是先注册(register)后查找的;使用时将它放在请求语句的前面。 而web_find是查找前面的请求结果;使用时将它放在请求语句的后面。
另二者的参数也完成不一样的,web_reg_find参数中SaveCount记录查找匹配的次数, web_find的机制是一旦查找匹配成功就立即返回,并不继续查找和记录匹配次数
再者Run-time设置中的“enable image and text check”对web_find有效,而对web_reg_find无效。 注意:web_find不支持URL模式下录制的脚本。
执行效率: web_reg_find可以直接在内存里面检查所指定对象是否存在;而web_find是文本检查点,需要对应页面完全显示出来之后,才会执行检查。概言之,使用web_reg_find不用启用文本检查点功能;使用web_find就一定要启用文本检查点功能,否则检查点无效。 很显然,前者比后者执行效率要高,这也是LR要不建议使用后者的原因。
以下是转海龙老师的 而web_reg_find()就不能通过它的返回值来作为事务的判断条件,因为web_reg_find()的返回值0和1表示web_reg_find()是否注册成功(web_reg_find是注册类型函数,它本身并不执行),并不代表查找的内容是否存在,也就是说无论查找的文本内容是否存在,都返回0,(和web_find的返回值意义就不同了)。
我想问的是有什么方法用web_reg_find()来作为事务的判断条件? 利用web_reg_find创建的参数SaveCount ,作为判断条件就可以了(如SaveCount >0)
web_find()(帮助不太推荐使用web_find而是推荐使用web_reg_find)要写在请求后,也就是要在事务内了。这样通过事务统计出来的响应时间就(包括了web_find()这个函数的执行时间)不真实了。而web_reg_find()是写在请求前面的。如果能用web_reg_find()来作为事务结束条件,那就是最好的. 事务时间等于Duration-Wasted Time,web_reg_find执行的时间Loadrunner会自动减掉的
另,LR自身已经提供了关于Page title的检查点的设置。路径: Recording setting >Advanced.
LR脚本实战:文本检查点web_reg_find和web_find两个函数的区别
 

脚本示例:
同样的script, 如果添加web_reg_find,事务运行结果失败:

Action.c(50): Error -26366: "Text=Dashboard" not found for web_reg_find          [MsgId: MERR-26366]

Action.c(50): web_submit_form("wp-login.php_2") highest severity level was "ERROR", 39882 body bytes, 3207 header bytes, 12 chunking overhead bytes          [MsgId: MMSG-26387]

Action.c(50): Notify: Transaction "Login_WordPress" ended with "Fail" status (Duration: 5.9267 Wasted Time: 0.0000).

Ending action Action.

Ending iteration 2.
 
而如果没有同,整个事务,包括 action运行成功:
 

Action.c(110): web_url("index-extra.php_5") was successful, 1047 body bytes, 2682 header bytes, 12 chunking overhead bytes          [MsgId: MMSG-26385]

Action.c(124): Log on successfully

Ending action Action.

Ending iteration 2.

 
 
Action()
{
 
int status; //定义变量,用于判断登陆是否成功
//    web_add_cookie("rtime=1; DOMAIN=bjdns2.cncmax.cn");
//
// web_add_cookie("ltime=1303876351121; DOMAIN=bjdns2.cncmax.cn");
//
// web_add_cookie("cnzz_eid=64563578-1302487037-http://bjdns2.cncmax.cn:8080/?HOST=home.beyondsoft.com&R=/& DOMAIN=bjdns2.cncmax.cn");
//
// web_add_cookie("JSESSIONID=E73D3BF7B18442F72B93F5EF37B5E545; DOMAIN=bjdns2.cncmax.cn");
 
web_url("bjdns2.cncmax.cn:8080",
"URL=http://bjdns2.cncmax.cn:8080/?HOST=wpad.beyondsoft.com&R=/wpad.dat&",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
 
// web_add_cookie("wp-settings-time-1=1304042778; DOMAIN=demo.opensourcecms.com");
//
// web_add_cookie("wordpress_test_cookie=WP+Cookie+check; DOMAIN=demo.opensourcecms.com");
//
// web_add_cookie("wordpress_logged_in_613541581fd3dd54ee5153849996d0f6=admin|1304215578|8148fb498981bf15c2f239b9d3dbdf5d; DOMAIN=demo.opensourcecms.com");
//
// web_add_cookie("wordpress_613541581fd3dd54ee5153849996d0f6=admin|1304215578|616ad0d48cfd28158b012254e00fe732; DOMAIN=demo.opensourcecms.com");
//
web_url("wp-login.php",
"URL=http://demo.opensourcecms.com/wordpress/wp-login.php",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"URL=wp-admin/images/button-grad.png", ENDITEM,
"URL=wp-admin/images/white-grad.png", ENDITEM,
"URL=wp-admin/images/logo-login.gif", ENDITEM,
LAST);
 
    
 
lr_start_transaction("Login_WordPress");
 
// 注意,该函数应该插入到提交时会出现该字段的地方之前。
  //web_reg_find("Text=Dashboard",
  // "Search=Body",
  // LAST);
web_submit_form("wp-login.php_2",
"Snapshot=t3.inf",
ITEMDATA,
"Name=log", "Value={UserName}", ENDITEM,
"Name=pwd", "Value={Password}", ENDITEM,
"Name=rememberme", "Value=<OFF>", ENDITEM,
"Name=wp-submit", "Value=Log In", ENDITEM,
EXTRARES,
"URL=wp-admin/images/wp-logo.png?ver=20100531", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/fav-arrow.gif?ver=20100531", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/menu.png?ver=20100531", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/menu-bits.gif?ver=20100610", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/menu-dark.gif", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/menu-arrows.gif", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/screen-options-toggle.gif?ver=20100531", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/icons32.png?ver=20100531", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/gray-grad.png", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-includes/js/thickbox/loadingAnimation.gif", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
"URL=wp-admin/images/fade-butt.png", "Referer=http://demo.opensourcecms.com/wordpress/wp-admin/", ENDITEM,
LAST);
 
 
lr_end_transaction("Login_WordPress", LR_AUTO);
 
web_url("index-extra.php",
"URL=http://demo.opensourcecms.com/wordpress/wp-admin/index-extra.php?jax=dashboard_incoming_links",
"Resource=0",
"RecContentType=text/html",
"Referer=http://demo.opensourcecms.com/wordpress/wp-admin/",
"Snapshot=t4.inf",
"Mode=HTML",
LAST);
 
web_url("index-extra.php_2",
"URL=http://demo.opensourcecms.com/wordpress/wp-admin/index-extra.php?jax=dashboard_primary",
"Resource=0",
"RecContentType=text/html",
"Referer=http://demo.opensourcecms.com/wordpress/wp-admin/",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
 
web_url("index-extra.php_3",
"URL=http://demo.opensourcecms.com/wordpress/wp-admin/index-extra.php?jax=dashboard_secondary",
"Resource=0",
"RecContentType=text/html",
"Referer=http://demo.opensourcecms.com/wordpress/wp-admin/",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
 
web_url("index-extra.php_4",
"URL=http://demo.opensourcecms.com/wordpress/wp-admin/index-extra.php?jax=dashboard_plugins",
"Resource=0",
"RecContentType=text/html",
"Referer=http://demo.opensourcecms.com/wordpress/wp-admin/",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
 
web_url("index-extra.php_5",
"URL=http://demo.opensourcecms.com/wordpress/wp-admin/index-extra.php?jax=dashboard_quick_press",
"Resource=0",
"RecContentType=text/html",
"Referer=http://demo.opensourcecms.com/wordpress/wp-admin/",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
 
if(status == LR_FAIL) {
lr_error_message("Log on failed");
return -1;
}
else{
lr_output_message("Log on successfully");
return 0;
}
 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值