為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) 的文字說明部分,這裡需要改成一樣的。
修改之後就沒有這個錯誤了。