参数化意义
1 比如注册某个系统时,用户名是不能有重复
2 模拟不同用户操作登录,更接近真实情况
案例参数化 webtours
业务数据参数化:
1 参数化的方法
2 参数之间的关联问题
3 参数取值问题
顺序(Sequential):按照参数化的数据顺序,一个一个的来取。
随机(Random):参数化中的数据,每次随机的从中抽取数据。
唯一(Unique):为每个虚拟用户分配一条唯一的数据 并发
4 并发,迭代,参数变化关系
================例子=================
Action()
{
web_reg_save_param("mysession","LB=userSession value=","RB=>",LAST);//
lr_log_message("mysession111 is %s",lr_eval_string("{mysession}")); //
web_reg_find("Text=Welcome,admin1", LAST); //check 的函数
web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, "Url=http://www.bing.com/favicon.ico", "Referer=", ENDITEM, LAST);
lr_log_message("mysession222 is %s",lr_eval_string("{mysession}"));
web_reg_find("Text=Welcome,admin1", "SaveCount=para_count111", LAST); //check 的函数
lr_think_time(17);
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=t9.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value={mysession}", ENDITEM,
"Name=username", "Value={username}", ENDITEM,
"Name=password", "Value={loginpwd}", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=43", ENDITEM,
"Name=login.y", "Value=4", ENDITEM,
LAST);
lr_log_message("username is %s",lr_eval_string("{username}"));
lr_log_message("pwd is %s",lr_eval_string("{loginpwd}"));
web_find("web_find","What=admin1", LAST);
web_image_check("web_image_check", "src=/images/signoff.gif",LAST);
//验证是否找到了页面上的要检查的字符串
if (atoi(lr_eval_string("{para_count111}"))>0) {
lr_output_message("login success!");
}
else{
lr_output_message("login error");
}
lr_think_time(5);
lr_output_message("1111111111111111111111111111");
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=t10.inf",
"Mode=HTML",
LAST);
lr_output_message("222222222222222222");
return 0;
}
网友评论