怎样做下载的检查点
(不一定要真的下载东西到文件夹,判断请求是否发送成功)
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中实现代码的重用