loadrunner 常用函数

本文详细介绍了LoadRunner中如何进行下载检查点的设置,函数封装,调用DLL文件,以及如何使用HTTP/HTML和WebService协议进行测试。同时讲解了脚本拆分、关联数组处理、字符串操作和JSON接口测试的方法,提供了一系列实用功能的示例,包括随机函数、字符串操作和数据保存等。
摘要由CSDN通过智能技术生成

怎样做下载的检查点
(不一定要真的下载东西到文件夹,判断请求是否发送成功)

int flen;
//your web url that download file
//get the download file's size
flen=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
if(flen>0)
{
   lr_end_transaction("S1_D_download",LR_AUTO);
}
else
{
   lr_end_transaction("S1_D_download",LR_FALL);
}

如何用LR保存下载的文件_2

 int i=0;
    int flen;
 long filedes;
//我们可以用web_reg_save_param 来指定某个地址来保存所有从服务器下载的字节

 web_reg_save_param("FILED",
  "LB=",
  "RB=",
  "NotFound=ERROR",
  "Search=Body",
  LAST);
  
        //your web url that download file
  //get the download file's size.
   flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

   if(flen>0)
  {
  //create a new file. If you run the script in contoller, you can use unique // name in Case 2 to generate a unique file.
     if((filedes = fopen("E:\\LoadRunner11_LOG\\FILEDOWMN.XLS","wb")) == NULL)
      {
       lr_error_message("文件打开失败!");
  
     lr_end_transaction("file_download", LR_FAIL);
        
      }
   //write the data which are got from server to the file created in your 
   //location
   // 
   else
    {
    
      i = fwrite(lr_eval_string("{FILED}"),flen,1,filedes);
   
      lr_output_message("文件写入成功! %d",i);
   
      lr_end_transaction("file_download",LR_AUTO);

怎样截取想要的字符串?

char *mystr = "I come from testroad";
  lr_save_var(mystr + 12, 8, 0, "Myschool");
  lr_output_message("My school is %s", lr_eval_string("{Myschool}"));
运行结果:Action.c(6): My school is testroad //从第12位开始截取8位

如何重新定义时间格式

char *ReqDate;

  lr_save_string("10/11/2006","MyDate");

  lr_save_var(lr_eval_string("{MyDate}"),2,0,"Date");

  lr_save_var(lr_eval_string("{MyDate}")+3,2,0,"Month");

  lr_save_var(lr_eval_string("{MyDate}")+6,4,0,"Year");

  ReqDate = lr_eval_string("{Month}/{Date}/{Year}");

  lr_output_message("date is % is",ReqDate);
Action.c(16): date is  27474608s

如何在LR中实现代码的重用

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值