loadrunner模拟文件上传代码示例

原创
2016/06/18 17:14
阅读数 745
Action(){
    long file_stream;
    char * PRPFILE =  "F:\\ELIFE保单号.txt";
	  char * num;
    char * PRPNum;
	  char * IP;

	  num = lr_eval_string("{num}");
	  IP = lr_get_vuser_ip();

	lr_start_transaction("elife-环球游-团单-团单导入上传");

	web_submit_data("commonUpload.do",
		"Action=http://11.207.60.3:8001/elife/policy/commonUploadAction/commonUpload.do",
		"Method=POST",
		"EncType=multipart/form-data",
		"RecContentType=text/html",
		"Referer=http://11.207.60.3:8001/elife/uploade.jsp",
		"Snapshot=t16.inf",
		"Mode=HTML",
		ITEMDATA,
//		"Name=sessionid", "Value=JS32100001EAJ1363727{CorrelationParameter_3}13031916{CorrelationParameter_4}", ENDITEM,
		"Name=sessionid", "Value=JS32100001EAJ{CorrelationParameter_4}", ENDITEM,
		"Name=uploadFile", "Value=E:\\elifetdimport.xls", "File=yes", ENDITEM,
		LAST);

	lr_output_message("session id: %s",lr_eval_string("{CorrelationParameter_4}"));
	lr_end_transaction("elife-环球游-团单-团单导入上传", LR_AUTO);

	lr_start_transaction("获取保单号");

	web_submit_data("qingfenAction.do",
		"Action=http://11.207.60.3:8001/elife/elife/QingfenAction/qingfenAction.do",
		"Method=POST",
		"Referer=http://11.207.60.3:8001/elife/policy/eAJPolicyAction/addEAJpolicy.do",
		"Mode=HTML",
		ITEMDATA,
		"Name=proposalnos", "Value={CorrelationParameter_2}", ENDITEM,
		"Name=next", "Value=0.0075899769244481274", ENDITEM,
		LAST);

	if(strcmp(lr_eval_string("{CorrelationParameter_2}")," ")!=0){
		lr_end_transaction("获取保单号", LR_PASS);
		PRPNum = lr_eval_string("{CorrelationParameter_2}");
		lr_log_message(" ---------------保单号:%s----------------",PRPNum);
			  if ((file_stream = fopen(PRPFILE, "a+")) == NULL ) {
		  lr_error_message("Cannot open %s", PRPFILE);
		  return -1;
		 }

		 fprintf(file_stream, "保单号:%s      发生在第%s次运行时    本机IP:%s\n", PRPNum,num,IP);
		 fclose(file_stream);
		 lr_log_message(" ---------------导出保单号:%s 成功,位置:%s----------------",PRPNum,PRPFILE);
	}else{
		lr_log_message("--------------获取保单号失败!-----------");
		lr_end_transaction("获取保单号", LR_FAIL);
	}
return 0;
}

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部