51Testing软件测试论坛
标题:
Loadrunner获取submit_data结果失败
[打印本页]
作者:
onlyyjw
时间:
2018-8-2 16:19
标题:
Loadrunner获取submit_data结果失败
int statue;
statue =web_submit_data("filePreUpload.do",
后面是文件上传到网盘的代码
lr_output_message(lr_eval_sting("{statue}"))
看直接结果日志中,文件上传成功了,但获取到的结果是0
作者:
qqq911
时间:
2018-8-27 10:56
换个中方式去验证服务器返回信息
作者:
梦想家
时间:
2018-8-27 11:54
https://blog.csdn.net/FloraCHY/article/details/72674543
作者:
jingzizx
时间:
2018-8-27 12:33
一般是校验返回值吧
作者:
qqq911
时间:
2018-8-28 10:39
换方式去验证服务器返回信息
作者:
104~牛牛
时间:
2018-8-28 10:45
分享详细讲解博客:
https://blog.csdn.net/testingstar/article/details/78106302
作者:
海海豚
时间:
2018-8-28 11:13
https://blog.csdn.net/FloraCHY/article/details/72674543
可以参考下这个
作者:
jingzizx
时间:
2018-8-28 13:12
常规做法是进行返回值的校验
作者:
libingyu135
时间:
2018-8-28 15:10
换方式去验证服务器返回信息
作者:
Refueling
时间:
2018-8-28 15:29
web_submit_data函数,成功返回0,失败返回1
1.录制一个示例脚本(登录),脚本内容如下:
Action()
{
web_url("booking",
"URL=http://localhost/test",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
/*进行登录操作*/
lr_think_time(8);
web_reg_find("Text=chenyinhua", //检查点
"SaveCount=a",
LAST);
web_submit_data("loginAction!loginQuick.action",
"Action=http://localhost/test/loginAction!loginQuick.action",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://localhost/test/",
"Snapshot=t8.inf",
"Mode=HTML",
ITEMDATA,
"Name=orderwebUser.userName", "Value=Y2hlbnlpbmh1YQ==/", ENDITEM,
"Name=userPassword", "Value=MTIzNDU2", ENDITEM,
"Name=certCode", "Value=1111", ENDITEM,
LAST);
return 0;
}
2.在脚本最开始,定义一个变量,用于判断登录是否成功
int status;
3.将web_submit_data的返回值赋值给status,如下:
status=web_submit_data("loginAction!loginQuick.action",
"Action=http://localhost/test/loginAction!loginQuick.action",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://localhost/test/",
"Snapshot=t8.inf",
"Mode=HTML",
ITEMDATA,
"Name=orderwebUser.userName", "Value=Y2hlbnlpbmh1YQ==/", ENDITEM,
"Name=userPassword", "Value=MTIzNDU2", ENDITEM,
"Name=certCode", "Value=1111", ENDITEM,
LAST);
4.写入一个判断,输出status的值
if(status==1) //一旦登录失败,脚本给出提示报错信息
{
lr_error_message("错误信息:%s","不能正常登录");
return -1;
}else if(status==0){
lr_output_message("登录成功。status=%d",status);
return 0;
}else{
lr_output_message("异常");
}
这里也可以用status的值,来判断登录事务是成功还是失败。
5.所以,整合后的脚本如下:
Action()
{
int status; //定义变量,用于判断登录是否成功
web_url("booking",
"URL=http://localhost/test",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
/*进行登录操作*/
lr_think_time(8);
web_reg_find("Text=chenyinhua",
"SaveCount=a",
LAST);
status=web_submit_data("loginAction!loginQuick.action",
"Action=http://localhost/test/loginAction!loginQuick.action",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://localhost/test/",
"Snapshot=t8.inf",
"Mode=HTML",
ITEMDATA,
"Name=orderwebUser.userName", "Value=Y2hlbnlpbmh1YQ==/", ENDITEM,
"Name=userPassword", "Value=MTIzNDU2", ENDITEM,
"Name=certCode", "Value=1111", ENDITEM,
LAST);
if(status==1) //一旦登录失败,脚本给出提示报错信息
{
lr_error_message("错误信息:%s","不能正常登录");
return -1;
}else if(status==0){
lr_output_message("登录成功。status=%d",status);
return 0;
}else{
lr_output_message("异常");
}
作者:
cclovely
时间:
2018-8-28 16:11
换种验证方式去获取返回结果
作者:
cclovely
时间:
2018-8-28 16:12
换种验证方式去获取返回结果
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2