51Testing软件测试论坛
标题:
求助:LR 下载文件,文件名参数化问题 [已解决,脚本没有问题,是我机器出了问题]
[打印本页]
作者:
bobble718
时间:
2009-7-10 17:08
标题:
求助:LR 下载文件,文件名参数化问题 [已解决,脚本没有问题,是我机器出了问题]
我用LR录制了一个下载文件的脚本,没有参数化之前,脚本可以将文件下载到本地,说明脚本是录制成功的。现在我将文件名进行了参数化,脚本也能运行通过,但是运行时弹出了一个对话框,请参见我上传的.jpg文件,运行后,我发现文件并没有下载到我指定的目录,而是在我脚本存放的位置生成了一个文件夹。下面是我参数化后的脚本:
Action()
{
int iflen;
long lfbody;
char file[1024];
strcpy(file,"f:\\");
strcat(file,lr_eval_string("{NewParam}"));
strcat(file,".doc");
web_custom_request("getMaterialCategoryAjax.action",
"URL=http://192.168.11.94/materialajax/getMaterialCategoryAjax.action",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.11.94/material/myMaterialAction.action",
"Snapshot=t4.inf",
"Mode=HTML",
"EncType=",
LAST);
//设置最大长度
web_set_max_html_param_len("100000");
//将响应信息存放到fcontent变量
web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=BODY", LAST);
web_url("showMyMaterialInfoAction.action",
"URL=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t5.inf",
"Mode=HTML",
EXTRARES,
"Url=../image/bg_header01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_body01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigation02.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_headerInfor02.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_headerInfor01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigation01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigationA01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigationA02.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigationA03.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigationA04.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigationA05.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_footer02.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_footer01.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_footer03.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=../image/bg_navigation01a.gif", "Referer=http://192.168.11.94/material/showMyMaterialInfoAction.action?materialId=9819", ENDITEM,
"Url=downloadMaterialAction.action?materialId=9819", "Referer=", ENDITEM,
LAST);
//获取响应大小
iflen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
if(iflen > 0)
{
//以写方式打开文件
if((lfbody = fopen(file, "wb")) == NULL)
{
lr_output_message("文件操作失败!");
return -1;
}
//写入文件内容
fwrite(lr_eval_string("{fcontent}"), iflen, 1, lfbody);
//关闭文件
fclose(lfbody);
}
return 0;
}
请高人们指点下,这是什么问题,我应该怎么改这个脚本,谢谢!
[
本帖最后由 bobble718 于 2009-7-10 18:17 编辑
]
作者:
qingyouzi777
时间:
2010-12-18 15:24
回复
1#
bobble718
你的脚本可以运行成功?
我的文件下载脚本和你的这个类似,但是编译时未通过,会提示这句代码:strcat(file,lr_eval_string("{NewParam}")); 有问题,貌似是不允许将char型变量和char型指针的连接。
作者:
qingyouzi777
时间:
2010-12-18 15:25
回复
1#
bobble718
还想请教一下,脚本没问题,机器出了什么问题?
作者:
msnshow
时间:
2010-12-18 17:55
很好,收藏
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2