资源描述:
《LoadRunner测试BS常用代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、如有错误,请及时修改并上传。一、随机删除声明变量:intcount,randcount;charrandflight[50],flightdel[50];执行语句:count=atoi(lr_eval_string("{fid_count}"));lr_output_message("随机数:%d",count);//输出语句srand(time(NULL));randcount=rand()%count+1;lr_output_message("随机数:%d",randcount);//输出语句lr_outp
2、ut_message("随机数:%d",count);//输出语句sprintf(randflight,"{fid_%d}",randcount);sprintf(flightdel,"Name=%s",randflight);修改:web_submit_form("itinerary.pl","Snapshot=t4.inf",ITEMDATA,//"Name=1","Value=",ENDITEM,//"Name=2","Value=",ENDITEM,//"Name=3","Value
3、=",ENDITEM,flightdel,"Value=on",ENDITEM,二、随机城市count=atoi(lr_eval_string("{city_count}"));srand(time(NULL));depart_num=rand()%count+1;if(depart_num==18)arrive_num=depart_num-1;elsearrive_num=depart_num+1;lr_output_message("起始城市下标为%d,目的城市下标%d",depart_num,
4、arrive_num);//输出语句sprintf(rand_depart_city,"{city_%d}",depart_num);sprintf(rand_arrive_city,"{city_%d}",arrive_num);sprintf(depart,"Value=%s",rand_depart_city);sprintf(arrive,"Value=%s",rand_arrive_city);三、随机购票n=atoi(lr_eval_string("{fight_count}"));srand(ti
5、me(NULL));m=rand()%(n-1)+2;sprintf(randfight,"{fight_%d}",m);sprintf(fightID,"Value=%s",randfight);四、不足5张票,继续购买flyon=atoi(lr_eval_string("{fly_count}"));lr_output_message("航班为%d",flyon);//输出语句if(flyon<5){buy();scan();}else{}五、删除两张票n=atoi(lr_eval_string("{fid
6、_count}"));lr_output_message("票数%d",n);//输出语句strcpy(str,"Body=1=on&flightID=");strcat(str,lr_eval_string("{fid_1}"));strcat(str,"&2=on&flightID=");strcat(str,lr_eval_string("{fid_2}"));lr_output_message("str=%s",str);lr_output_message("n=%d",n);for(i=1;i<=n-
7、2;i++){strcat(str,"&flightID=");sprintf(flight,"{fid_%d}",i+2);lr_output_message("flight=%s",flight);strcat(str,flight);lr_output_message("str=%s",str);}strcat(str,"&.cgifields=1&.cgifields=2");坐标:strcat(str,"&removeFlights.x=81&removeFlights.y=7");lr_output
8、_message(str);//输出语句六、下载srand(time(NULL));num=rand()%100;sprintf(str,"%d",num);strcpy(filename,"D:\test\test");strcat(filename,str);strcat(filename,".png");web_reg_save_param("content","LB=","