loadrunner-增加检查点(web_reg_find)

时间:2023-03-08 21:45:23
接口性能测试地址:
http://192.168.x.x:x/tionWeb/Ajax_GetStock.aspx?stockcode=600571
性能测试脚本:
Action()
{ lr_start_transaction(""); web_reg_find("Text=600571",
"Search=body",
"SaveCount=n",
LAST); web_url("Ajax_GetStock.aspx",
"URL=http://192.168.x.x:x/tionWeb/Ajax_GetStock.aspx?stockcode=600571",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTTP",
LAST); if(atoi(lr_eval_string("{n}"))>=){ lr_end_transaction("",LR_PASS);
} else{
lr_end_transaction("",LR_FAIL); } return ;
}

说明:

  •  web_reg_find()检查点函数:
     web_reg_find("Text=600571",
"Search=body",
"SaveCount=n",
LAST);
  • SaveCount:统计待检查数据被检查到的次数,确定一个事务是否成功,那么至少待检查的数据至少要被检查找到一次:    
    if(atoi(lr_eval_string("{n}"))>=1){

        lr_end_transaction("01",LR_PASS);
} else{
lr_end_transaction("01",LR_FAIL); }

    

     lr_eval_string():读取变量n的值
atoi():转化成整型