LoadRunner脚本

时间:2021-10-06 19:36:45

Action()

{

char *str1=(char *)malloc(1024*sizeof(char));

char *str2="0";

char *str3=(char *)malloc(1024*sizeof(char));

char *str4=(char *)malloc(1024*sizeof(char));

char *str5=(char *)malloc(1024*sizeof(char));

int num;

lr_save_string("{\"merchant_id\":\"1\",\"merchant_token\":\"\",\"token\":\"","str6");

lr_save_string("\",\"user_id\":\"","str7");

lr_save_string("\",\"data_version\":\"1.1.0\"}","str8");

web_add_auto_header("User-Agent", lr_eval_string("{str6}{token}{str7}{userid}{str8}"));

lr_save_string(str2,"update_id");

do {

web_reg_save_param_ex(

"ParamName=data_status",

"LB=\"data_status\":\"",

"RB=\"",

"NotFound=warning",

SEARCH_FILTERS,

LAST);

web_reg_save_param_ex(

"ParamName=update_id",

"LB=\"update_id\":\"",

"RB=\"",

"Ordinal=all",

"NotFound=warning",

SEARCH_FILTERS,

LAST);

web_reg_save_param_ex(

"ParamName=status",

"LB=\"status\":",

"RB=,",

SEARCH_FILTERS,

LAST);

web_reg_save_param_ex(

"ParamName=code",

"LB=\"code\":",

"RB=,",

SEARCH_FILTERS,

LAST);

lr_start_transaction("差异下载");

web_url("different_download",

"URL=http://appapi.pj.damai.cn/ticket/different_download?update_id={update_id }",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://appapi.pj.damai.cn/doc/index.html ",

"Snapshot=t3.inf",

"Mode=HTML",

LAST);

lr_end_transaction("差异下载", LR_AUTO);

lr_free_parameter("update_id");

lr_output_message(lr_eval_string("{update_id}"));

num=atoi(lr_eval_string("{update_id_count}"));

str3 =lr_paramarr_idx("update_id",num);

str1 =lr_eval_string("{data_status}");

lr_save_string(str3,"update_id");

str4 =lr_eval_string("{status}");

str5 =lr_eval_string("{code}");

if (strcmp(str4,"200") ==0 && strcmp(str5,"0") == 0)

  lr_output_message("差异下载成功 status:%s,code:%s",str4,str5);

else

  lr_error_message("差异下载失败 status:%s,code:%s",str4,str5);

lr_free_parameter("status");

lr_free_parameter("code");

lr_free_parameter("update_id_count");

lr_free_parameter("data_status");

free(str3);

free(str4);

free(str5);

}

while (strcmp(str1,"0") ==0);

free(str1);

return 0;

}