Loadrunner获取submit_data结果失败
int statue;statue =web_submit_data("filePreUpload.do",
后面是文件上传到网盘的代码
lr_output_message(lr_eval_sting("{statue}"))
看直接结果日志中,文件上传成功了,但获取到的结果是0 换个中方式去验证服务器返回信息 https://blog.csdn.net/FloraCHY/article/details/72674543 一般是校验返回值吧 换方式去验证服务器返回信息
分享详细讲解博客:https://blog.csdn.net/testingstar/article/details/78106302 https://blog.csdn.net/FloraCHY/article/details/72674543 可以参考下这个 常规做法是进行返回值的校验
换方式去验证服务器返回信息 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("异常");
} 换种验证方式去获取返回结果 换种验证方式去获取返回结果
页:
[1]