|
3#
楼主 |
发表于 2007-10-25 15:04:35
|
只看该作者
我还是贴出来吧 比较直接
//目的:获取如下图中的值(实现任意选择 )
//运行结果:
//Action.c(97): 错误 -27979: 找不到请求的表单 [MsgId: MERR-27979]
//Action.c(97): web_submit_form("reservations.pl_2") 最高严重级别为“ERROR”,0 个正文字节,0 个标头字节 [MsgId: MMSG-26388]
//--------------------------------------------------------------------------------------------------
Action()
{
//declare variables
int i, ItemNumCount, RandNum;
char* temp;
char RandNumStr[20];
char namestr[20];
web_reg_save_param("ItemId", "LB=value=", "RB=>", "ORD=ALL", LAST);
web_url("welcome.pl",
"URL=http://127.0.0.1:1080/mercuryWebTours/welcome.pl?page=search",
"Resource=0",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home",
"Snapshot=t3.inf",
"Mode=HTML",
LAST);
lr_think_time(7);
web_url("FormDateUpdate.class",
"URL=http://127.0.0.1:1080/mercuryWebTours/FormDateUpdate.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);
web_url("CalSelect.class",
"URL=http://127.0.0.1:1080/mercuryWebTours/CalSelect.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);
web_url("Calendar.class",
"URL=http://127.0.0.1:1080/mercuryWebTours/Calendar.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);
lr_think_time(13);
web_submit_data("reservations.pl",
"Action=http://127.0.0.1:1080/mercuryWebTours/reservations.pl",
"Method=POST",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/mercuryWebTours/reservations.pl?page=welcome",
"Snapshot=t4.inf",
"Mode=HTML",
ITEMDATA,
"Name=advanceDiscount", "Value=0", ENDITEM,
"Name=depart", "Value=Denver", ENDITEM,
"Name=departDate", "Value=10/26/2007", ENDITEM,
"Name=arrive", "Value=London", ENDITEM,
"Name=returnDate", "Value=10/27/2007", ENDITEM,
"Name=numPassengers", "Value=2", ENDITEM,
"Name=seatPref", "Value=Window", ENDITEM,
"Name=seatType", "Value=Business", ENDITEM,
"Name=.cgifields", "Value=roundtrip", ENDITEM,
"Name=.cgifields", "Value=seatType", ENDITEM,
"Name=.cgifields", "Value=seatPref", ENDITEM,
"Name=findFlights.x", "Value=40", ENDITEM,
"Name=findFlights.y", "Value=11", ENDITEM,
LAST);
lr_think_time(6);
//get the count of flightList array
ItemNumCount = atoi(lr_eval_string("{ItemId_count}"));
for (i=1;i <=ItemNumCount;i++) {
sprintf(namestr, "{namestr_%i}", i);}
//save namestr to String Tempnamestr
lr_save_string(lr_eval_string(namestr), "Tempnamestr");
//Generate a Random Number
RandNum = 1 + rand() % ItemNumCount;
//Save Random Number to String
itoa (RandNum,RandNumStr,20);
//Display Random Number in Log
lr_output_message("Random Number Generated is :%s", lr_eval_string(RandNumStr));
//Saves RandNumStr into random_value and then into temp
lr_save_string(RandNumStr, "random_value");
temp = lr_eval_string(lr_eval_string("{ItemNumArray_{random_value}}"));
lr_save_string(temp, "RandItemNum");
//Use RandNumStr variable in a web_submit_form step
web_submit_form("reservations.pl_2",
"Snapshot=t5.inf",
ITEMDATA,
//"Name=outboundFlight", "Value=021;437;10/26/2007", ENDITEM,
"Name=outboundFlight", "Value={RandItemNum}", ENDITEM,
"Name=reserveFlights.x", "Value=22", ENDITEM,
"Name=reserveFlights.y", "Value=9", ENDITEM,
LAST);
lr_think_time(52);
web_submit_form("reservations.pl_3",
"Snapshot=t6.inf",
ITEMDATA,
"Name=firstName", "Value=L", ENDITEM,
"Name=lastName", "Value=LM", ENDITEM,
"Name=address1", "Value=Peking 99", ENDITEM,
"Name=address2", "Value=Peking/China/100000", ENDITEM,
"Name=pass1", "Value= L", ENDITEM,
"Name=pass2", "Value=C", ENDITEM,
"Name=creditCard", "Value=2245657889090-054320", ENDITEM,
"Name=expDate", "Value=06/10", ENDITEM,
"Name=saveCC", "Value=on", ENDITEM,
"Name=buyFlights.x", "Value=32", ENDITEM,
"Name=buyFlights.y", "Value=16", ENDITEM,
LAST);
return 0;
} |
|