为LoadRunner12生成的脚本插入登录检查点运行之后报了这个错误
修改之前的代码如下:
web_concurrent_start(NULL);
lr_start_transaction("开始登录");//事务开始
web_reg_find("Fail=NotFound",
"Search=Body",
"SaveCount=loginCheck",
"Text=Welcome",
LAST);//检查点,判断登录之后的页面中的Body部分是否包含Welcome
web_url("login.pl_2",
"URL=http://localhost:1080/cgi-bin/login.pl?intro=true",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost:1080/cgi-bin/login.pl",
"Snapshot=t72.inf",
"Mode=HTTP",
LAST);
web_url("nav.pl_2",
"URL=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=home",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost:1080/cgi-bin/login.pl",
"Snapshot=t73.inf",
"Mode=HTTP",
LAST);
web_concurrent_end(NULL);
if((atoi(lr_eval_string("{loginCheck}")))>0){
lr_end_transaction("登录成功", LR_PASS);//事务结束
}else{
lr_end_transaction("登录失败", LR_FAIL);//事务结束
}/* 判断{loginCheck}是否包含了需要检查的文段,页面中包含了说明登录
成功,没有包含则登录失败. lr_eval_string指返回脚本参数中的值,
lr_eval_string("{loginCheck}")就是返回参数loginCheck的值;
atoi是把字符串转换成整型数。*/
修改之后的代码:
web_concurrent_start(NULL);
lr_start_transaction("开始登录");
web_reg_find("Fail=NotFound",
"Search=Body",
"SaveCount=loginCheck",
"Text=Welcome",
LAST);
web_url("login.pl_2",
"URL=http://localhost:1080/cgi-bin/login.pl?intro=true",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost:1080/cgi-bin/login.pl",
"Snapshot=t72.inf",
"Mode=HTTP",
LAST);
web_url("nav.pl_2",
"URL=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=home",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost:1080/cgi-bin/login.pl",
"Snapshot=t73.inf",
"Mode=HTTP",
LAST);
web_concurrent_end(NULL);
if((atoi(lr_eval_string("{loginCheck}")))>0){
lr_end_transaction("开始登录", LR_PASS);
}else{
lr_end_transaction("开始登录", LR_FAIL);
}
两段代码的区别在于,lr_start_transaction(“开始登录”) 和lr_end_transaction(“开始登录”, LR_PASS) 的文字说明部分,这里需要改成一样的。
修改之后就没有这个错误了。