lr下载文件脚本

上一篇 / 下一篇  2008-11-27 10:01:04 / 个人分类:测试工具

Action()
{
 int iflen;    //文件大小
 long lfbody;  //响应数据内容大小
 char *string;  
 web_set_max_html_param_len("60000000");  //设置最大长度

 web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=BODY", LAST); 

  //将响应信息存放到fcontent变量

 web_url("下载页面",
         "URL=http://192.168.20.160/DownLoad/DownLoad/download.aspx?  DownType=caj&Page=&Email=&FileName={NewParam}&FileTitle={NewParam}&DBCode=cmfd&Version=2.0",  //文件下载路径
  "Resource=0",
  "RecContentType=text/html",
  "Referer=http://192.168.20.160/DownLoad/DownLoad",  //可为空"Referer=",
  "Snapshot=t3.inf",
  "Mode=HTML",
  LAST);
  string=lr_eval_string("E:\\{NewParam}.caj");  //NewParam中存放着源数据文件名
  lr_message(string);
//lr_output_message("####%s",lr_eval_string("{NewParam}"));  //输出当前参数取值

iflen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
  if(iflen > 0)
 {
    //以写方式打开文件
    if((lfbody = fopen(string, "wb")) == NULL)
      {
        lr_output_message("文件操作失败!");
        return -1;
      }
    //写入文件内容
    fwrite(lr_eval_string("{fcontent}"), iflen, 1, lfbody);
    //关闭文件
    fclose(lfbody);
      }
     return 0;
}
    int flen,rNum;   //定义一个整型变量保存获得文件的大小
    long filedes;    //保存文件句柄
    char filepath[512],filename[512];  //保存文件路径及文件名

    rNum = rand() % 10000000;  //生成一个随机的文件全路径名
    itoa(rNum, filename, 10);  //filename形式为随机5位数字:29224,18916,……
   
    strcpy(filepath,"E:\\");
    strcat(filepath,filename);
    strcat(filepath,".caj");
                               //filepath为E:\\filename.caj
    lr_message(filepath);


TAG: LoadRunner loadRunner

让测试飞起来的个人空间 引用 删除 让测试飞起来   /   2014-02-27 14:48:43
5
 

评分:0

我来说两句

guobin_it

guobin_it

软件测试技术交流群60926703 (已满) CDN流媒体测试技术交流群126760166 (未满)

日历

« 2024-04-08  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 107812
  • 日志数: 57
  • 建立时间: 2007-12-14
  • 更新时间: 2011-07-07

RSS订阅

Open Toolbar