码迷,mamicode.com
首页 > 其他好文 > 详细

关联、参数化、思考时间、检查点、事务的设置方式

时间:2016-01-31 13:10:22      阅读:361      评论:0      收藏:0      [点我收藏+]

标签:

Action()
{

//如果关联的数据过于长,需要在这里将参数存储的值变大
web_set_max_html_param_len("1024");

//登陆关联,关联函数就是通过指定的左右边界来获取值的。 如果将加载首页放在vuser_Init或者关联函数前面,执行会报错,
//错误 -26377: 找不到所请求参数“userSessionlogin”的匹配项。请检查响应数据中是否存在请求的边界
web_reg_save_param_ex(
"ParamName=CorrelationParameter_1", //关联的名称,可自定义
"LB=userSession value=", //左边界
"RB=>\n<table border", //右边界
SEARCH_FILTERS,
"Scope=All",
"IgnoreRedirections=Yes",
"RequestUrl=*/nav.pl*",
LAST);


//首页加载插入事务,检查响应时间
lr_start_transaction("the_first_page_load");
//首页加载


web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);

lr_end_transaction("the_first_page_load",LR_AUTO);

lr_think_time(3); //思考时间设置3秒,如果需要启动的话,需要在run_time settings>general>think time 去掉勾选的ignore think time设置


//检查点设置,检查登陆成功页面是否有显示用户名,如有,则事务执行成功


web_reg_find("Search=All",
"SaveCount=SaveCountFail",
"Text=Web Tours Error - Incorrect Password",
LAST);

 

//登陆事务
lr_start_transaction("login");

//登陆页面,输入账号和密码

/* Request with GET method to URL "http://127.0.0.1:1080/favicon.ico" failed during recording. Server response : 404*/

/* Request with GET method to URL "http://bho.xl7.xunlei.com/platform/2.6.x.xxxx/config.xml" failed during recording. Server response : 404*/

lr_think_time(12);

web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/WebTours/login.pl",
"Method=POST",
"TargetFrame=body",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
"Snapshot=t3.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value={CorrelationParameter_1}", ENDITEM,
"Name=username", "Value={username}", ENDITEM,
"Name=password", "Value={password}", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=70", ENDITEM,
"Name=login.y", "Value=20", ENDITEM,
LAST);

 

lr_output_message("关联输出的字符串:%s",lr_eval_string("{CorrelationParameter_1}"));

//如果参数化的密码是错误的,这里的判断有问题,密码是错误的,web_reg_find查找的是username参数化,SaveCountFail应该返回0才对,但是返回却是2,而输入正确的用户名和密码反而SaveCountFail变成0,这个问题待解决
// 以上问题的解决思路是反向操作,web_reg_find查找Web Tours Error - Incorrect Password,如果找到,则登陆失败,如果找不到,则登陆成功,可以解决上面问题
//判断事务是否执行成功
if (atoi(lr_eval_string("{SaveCountFail}"))!=0)
{
lr_end_transaction("login",LR_FAIL);
lr_log_message("find the number:%s",lr_eval_string("{SaveCountFail}"));
lr_log_message("login fail,username:%s",lr_eval_string("{username}"));
lr_log_message("login fail,password:%s",lr_eval_string("{password}"));

}


else

{

lr_end_transaction("login",LR_PASS);
lr_log_message("find the number:%s",lr_eval_string("{SaveCountFail}"));
lr_output_message("success");
//输出用户名和密码
lr_log_message("the correct username:%s",lr_eval_string("{username}"));
lr_log_message("the correct password:%s",lr_eval_string("{password}"));
}


lr_think_time(3);

lr_start_transaction("loginout");

lr_think_time(21);

web_url("SignOff Button",
"URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",
"TargetFrame=body",
"Resource=0",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",
"Snapshot=t4.inf",
"Mode=HTML",
LAST);

lr_end_transaction("loginout",LR_AUTO);

return 0;
}

关联、参数化、思考时间、检查点、事务的设置方式

标签:

原文地址:http://www.cnblogs.com/zhangyublogs/p/5172866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!