Loadrunner获取响应里面的内容
Posted 给天使看的戲
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Loadrunner获取响应里面的内容相关的知识,希望对你有一定的参考价值。
通过以下设置可获取到 Response Body(响应)里面的内容;
Action()
{
lr_rendezvous("登录集合点");
lr_start_transaction("login");
web_reg_save_param("result","LB=","RB=","Search=Body",LAST); // 根据左右边界截取整个返回值,并且将返回值存在变量result中
web_custom_request("login_3",
"URL=http://{XXXXXXXXX}/api/gv-op/userAuth/login",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://{host_test_line_meltiot_com_8060}/login",
"Snapshot=t7.inf",
"Mode=html",
"EncType=application/json",
"Body={\\"account\\":\\"guest_Pai_shz\\",\\"password\\":\\"PW_Pai_shz\\"}", // 用户名和密码
EXTRARES,
"Url=getLocalUser", "Referer=http://{XXXXXXXXX}/login", ENDITEM,
"Url=/js/chunk-02033ae8.e34668fd.js", "Referer=http://{XXXXXXXXX}/login", ENDITEM,
"Url=/js/chunk-65196f87.36c57733.js", "Referer=http://{XXXXXXXXX}/login", ENDITEM,
"Url=/img/IOT.fb800d2e.jpg", "Referer=http://{XXXXXXXXX}/device-info", ENDITEM,
"Url=../sysDict/getDictsByType?type=runStatusType", "Referer=http://{XXXXXXXXX}/device-info", ENDITEM,
"Url=../sysDict/getDictsByType?type=workStatusType", "Referer=http://{XXXXXXXXX}/device-info", ENDITEM,
"Url=../sysDict/getDictsByType?type=deviceAlarmStatus", "Referer=http://{XXXXXXXXX}/device-info", ENDITEM,
"Url=../deviceInfo/pageList?serialNum=&pole=&runStatus=&workStatus=&deviceAlarmStatus=¤t=1&size=10", "Referer=http://{XXXXXXXXX}/device-info", ENDITEM,
LAST);
lr_convert_string_encoding(lr_eval_string("{result}"),"utf-8",NULL,"msg");//获取到的Response body进行转码并保存到 msg 中;
lr_output_message("login转换编码后是:%s",lr_eval_string("{msg}")); //输出转码后的 body ;
lr_end_transaction("login",LR_AUTO);
return 0;
}
运行后得到:
Virtual User Script started at : 2021/5/28 16:43:10 ...... ...... Action.c(17): Warning -26373: Parameter "result" saved from a resource (URL="http://XXXXXXX:8060/api/gv-op/sysDict/getDictsByType?type=deviceAlarmStatus") [MsgId: MWAR-26373] |
以上是关于Loadrunner获取响应里面的内容的主要内容,如果未能解决你的问题,请参考以下文章