51Testing软件测试论坛
标题:
回放脚本很多步骤没有快照
[打印本页]
作者:
flyly0755
时间:
2017-3-28 14:15
标题:
回放脚本很多步骤没有快照
本帖最后由 flyly0755 于 2017-3-28 14:18 编辑
最近使用loadrunner进行API接口测试,遇到下面这样一个的问题:
一个脚本里面有四个消息交互流程,第一个是POST, 其他三个是GET.
回放之后只有第一个步骤生成了快照,其他三个步骤都没有快照,消息交互没有问题,脚本如下:
Action()
{
//变量在最前面定义
int HttpRetCode;
int i,j;
lr_start_transaction("GetToken");
// 默认最大长度为256
web_set_max_html_param_len("262144");
//获取Token
web_reg_save_param("Token","LB=\"access_token\":\"","RB=\"",LAST);
web_submit_data("
bazhuayuAPI-step1
"
"Action=http://dataapi.bazhuayu.com/token",
"Method=
POST
",
"RecContentType=application/x-www-form-urlencoded",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTTP",
ITEMDATA,
"Name=username", "Value={test01}", ENDITEM,
"Name=password", "Value=123456", ENDITEM,
"Name=grant_type", "Value=password", ENDITEM,
LAST);
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (HttpRetCode == 200)
lr_end_transaction("GetToken", LR_PASS);
else
lr_end_transaction("GetToken", LR_FAIL);
lr_start_transaction("GetSpecificTaskGroupInfo");
//web_reg_save_param("taskGroupName","LB=\"taskGroupName\":\"","RB=\"",,LAST);
web_reg_save_param("taskGroupIdget","LB=\"taskGroupId\":","RB=,\"taskGroupName\":\"testAPIgp1\"",LAST);
web_save_header(RESPONSE, "ResponseHeader");// RESPONSE保存响应的头信息
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_add_header("Authorization","bearer {Token}"); //"Authorization=bearer {Token}",
web_submit_data("
bazhuayuAPI-step2
",
"Action=http://dataapi.bazhuayu.com/api/taskgroup",
"Method=
GET
",
"RecContentType=application/x-www-form-urlencoded",
"Snapshot=t2.inf",
"Mode=HTTP",
LAST );
lr_output_message("响应内容体:\n %s", lr_eval_string("{ResponseBody}"));
lr_output_message("测试任务组id:%s", lr_eval_string("{taskGroupIdget}"));
lr_end_transaction("GetSpecificTaskGroupInfo", LR_PASS);
lr_start_transaction("GetSpecificTaskInfo");
web_reg_save_param("taskIdget","LB=\"taskId\":\"","RB=\",\"taskName\":\"testAPIgp1task1\"",LAST);
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_add_header("Authorization","bearer {Token}"); //"Authorization=bearer {Token}",
web_submit_data("
bazhuayuAPI-step3
",
"Action=http://dataapi.bazhuayu.com/api/task",
"Method=
GET
",
"RecContentType=application/json",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
ITEMDATA,
"Name=taskgroupid", "Value={taskGroupIdget}", ENDITEM,
LAST);
lr_output_message("响应内容体:\n %s", lr_eval_string("{ResponseBody}"));
lr_output_message("测试任务id:%s", lr_eval_string("{taskIdget}"));
lr_end_transaction("GetSpecificTaskInfo", LR_PASS);
lr_start_transaction("GetSpecificTaskData");
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_add_header("Authorization","bearer {Token}"); //"Authorization=bearer {Token}",
web_submit_data("
bazhuayuAPI-step4
",
"Action=http://dataapi.bazhuayu.com/api/alldata",
//"Action=str1",
"Method=
GET
",
"RecContentType=application/json",
"Mode=HTTP",
"Snapshot=t4.inf",
ITEMDATA,
"Name=taskid","Value={taskIdget}",ENDITEM,
"Name=pageindex","Value=1",ENDITEM,
"Name=pagesize","Value=5",ENDITEM,
LAST );
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),"utf-8",NULL,"ResponseBodyChs");
lr_output_message("# 响应内容体:\n %s", lr_eval_string("{ResponseBodyChs}"));
lr_end_transaction("GetSpecificTaskData", LR_PASS);
return 0;
}
使用LR 11中文破解版。疑惑中,在此请求各位LR大牛。
PS: 第一个方法是POST, 后三个方法是GET, 和这个有关系么?
作者:
flyly0755
时间:
2017-3-30 12:14
木有大牛回复么
作者:
flyly0755
时间:
2017-4-6 18:20
顶一下,别沉了!
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2