Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1825494
  • 博文数量: 323
  • 博客积分: 5970
  • 博客等级: 大校
  • 技术积分: 2764
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-03 23:13
文章分类

全部博文(323)

文章存档

2018年(2)

2017年(11)

2016年(10)

2015年(27)

2014年(2)

2013年(30)

2012年(197)

2011年(44)

分类: WINDOWS

2012-06-13 17:17:50

WebTours取消一个订单的脚本

char requestStr[2000];//用于拼装关联到的flightID和cgifields,如果订单过多,数组可能会越界
char tmpStr[50];

int count=0;
int i=1;

Action()
{

 lr_start_transaction("WebTours_取消订单");

 lr_think_time(52);

 web_url("welcome.pl_2", 
  "URL=", 
  "Resource=0", 
  "RecContentType=text/html", 
  "Referer=", 
  "Snapshot=t16.inf", 
  "Mode=HTTP", 
  LAST);

 web_concurrent_start(NULL);

 web_url("nav.pl_3", 
  "URL=", 
  "Resource=0", 
  "RecContentType=text/html", 
  "Referer=", 
  "Snapshot=t17.inf", 
  "Mode=HTTP", 
  LAST);

 //关联全部订单的flightID
   web_reg_save_param(
  "flightID",
  "LB=name=\"flightID\" value=\"",
  "RB=\"",
  "ORD=ALL",
  LAST);

   //关联全部订单的cgifields
 web_reg_save_param(
  "cgifilelds",
  "LB=name=\".cgifields\" value=\"",
  "RB=\"",
  "ORD=ALL",
  LAST);

 web_url("itinerary.pl", 
  "URL=", 
  "Resource=0", 
  "RecContentType=text/html", 
  "Referer=", 
  "Snapshot=t20.inf", 
  "Mode=HTTP", 
  LAST);

 web_concurrent_end(NULL);

 web_concurrent_start(NULL);

 web_url("in_itinerary.gif", 
  "URL=http://127.0.0.1:1080/WebTours/images/in_itinerary.gif", 
  "Resource=1", 
  "RecContentType=image/gif", 
  "Referer=", 
  "Snapshot=t18.inf", 
  LAST);

 web_url("home.gif", 
  "URL=http://127.0.0.1:1080/WebTours/images/home.gif", 
  "Resource=1", 
  "RecContentType=image/gif", 
  "Referer=", 
  "Snapshot=t19.inf", 
  LAST);

 web_concurrent_end(NULL);


 web_concurrent_start(NULL);

 web_url("cancelreservation.gif", 
  "URL=http://127.0.0.1:1080/WebTours/images/cancelreservation.gif", 
  "Resource=1", 
  "RecContentType=image/gif", 
  "Referer=", 
  "Snapshot=t21.inf", 
  LAST);

 web_url("cancelallreservations.gif", 
  "URL=http://127.0.0.1:1080/WebTours/images/cancelallreservations.gif", 
  "Resource=1", 
  "RecContentType=image/gif", 
  "Referer=", 
  "Snapshot=t22.inf", 
  LAST);

 web_concurrent_end(NULL);

 lr_think_time(24);

 //以下代码对关联到的flightID和cgifilelds进行组包

 //获取关联到的flightID的数量
    count=atoi(lr_eval_string("{flightID_count}"));

 if(count != 0 )
 {
  strcat(requestStr,"Body=1=on");

  for(;i<=count;i++)
  {//获取所有的flightID值
   strcat(requestStr,"&flightID=");
   //lr_output_message(lr_eval_string("{flightID_1}"));
   sprintf(tmpStr,"{flightID_%d}",i); 
   //lr_output_message("%s\n",lr_eval_string(tmpStr));
   strcat(requestStr,lr_eval_string(tmpStr));
  }

  i=1;

  for(;i<=count;i++)
  {//获取所有的cgifields值
   strcat(requestStr,"&.cgifields=");
   sprintf(tmpStr,"{cgifilelds_%d}",i);
   strcat(requestStr,lr_eval_string(tmpStr));
  }

  strcat(requestStr,"&removeFlights.x=57&removeFlights.y=13");

 /*在这里,我们使用web_custom_request替换web_submit_data*/
 web_custom_request("itinerary.pl_2", 
  "Method=POST", 
  "URL=",   
  "RecContentType=text/html", 
        requestStr,
        "Snapshot=t23.inf",
  LAST);

  lr_end_transaction("WebTours_取消订单",LR_AUTO);

 }
    else
 {
        lr_end_transaction("WebTours_取消订单",LR_FAIL);
 }

/**录制时的方法,向服务器提交表单
 web_submit_data("itinerary.pl_2", 
  "Action=", 
  "Method=POST", 
  "RecContentType=text/html", 
  "Referer=", 
  "Snapshot=t23.inf", 
  "Mode=HTTP", 
  ITEMDATA, 
  "Name=1", "Value=on", ENDITEM, 
  "Name=flightID", "Value={flightID}", ENDITEM, 
  "Name=flightID", "Value=292222653-1588-t0", ENDITEM, 
  "Name=flightID", "Value=120074863-2330-t0", ENDITEM, 
  "Name=flightID", "Value=1238518-30-t0", ENDITEM, 
  "Name=flightID", "Value=292223728-3896-t0", ENDITEM, 
  "Name=flightID", "Value=292226685-4653-t0", ENDITEM, 
  "Name=flightID", "Value=292230018-5423-t0", ENDITEM, 
  "Name=flightID", "Value=292234845-6217-t0", ENDITEM, 
  "Name=flightID", "Value=2922392635-69320-t0", ENDITEM, 
  "Name=.cgifields", "Value={cgifilelds}", ENDITEM, 
  "Name=.cgifields", "Value=3", ENDITEM, 
  "Name=.cgifields", "Value=7", ENDITEM, 
  "Name=.cgifields", "Value=9", ENDITEM, 
  "Name=.cgifields", "Value=2", ENDITEM, 
  "Name=.cgifields", "Value=8", ENDITEM, 
  "Name=.cgifields", "Value=1", ENDITEM, 
  "Name=.cgifields", "Value=4", ENDITEM, 
  "Name=.cgifields", "Value=5", ENDITEM, 
  "Name=removeFlights.x", "Value=57", ENDITEM, 
  "Name=removeFlights.y", "Value=13", ENDITEM, 
  LAST);
*/
 /*  以下这些内容是录制时向服务器发送的请求
  1=on&flightID=292226720-803-t0&flightID=292222653-1588-t0&flightID=120074863-2330-t0
  &flightID=1238518-30-t0&flightID=292223728-3896-t0&flightID=292226685-4653-t0
  &flightID=292230018-5423-t0&flightID=292234845-6217-t0&flightID=2922392635-69320-t0
  &.cgifields=6&.cgifields=3&.cgifields=7&.cgifields=9&.cgifields=2&.cgifields=8
  &.cgifields=1&.cgifields=4&.cgifields=5&removeFlights.x=57&removeFlights.y=13
*/
 //lr_output_message("=====================================%s\n",requestStr);

 return 0;
}

阅读(1804) | 评论(0) | 转发(0) |
0

上一篇:loadrunner小技巧汇总

下一篇:c枚举的使用

给主人留下些什么吧!~~