yangxiaojing_6 发表于 2009-12-25 10:38:31

LR脚本加入check_text函数后报错

录制脚本如下:红色为录制后手工修改的。
该脚本是针对LR自带的webtours系统进行录制,基于HTML格式。
红色脚本部分,对登录是否成功进行检查。针对if判断为真时,脚本能够成功回放,当我把用户名jojo改成jojo1时回放会报错:


Action.c(45): Error -27987: Requested image not found   
Action.c(45): web_image("Search Flights Button") highest severity level was "ERROR", 0 body bytes, 0 header bytes   



Action()
{
int count;
web_url("WebTours",
"URL=http://192.168.1.224:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
lr_start_transaction("login");
lr_think_time(92);
web_reg_find("Search=Body",
"SaveCount=check_1",
"Text=to the Web Tours reservation pages",
LAST);
web_submit_form("login.pl",
"Snapshot=t2.inf",
ITEMDATA,
"Name=username", "Value=jojo1", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=63", ENDITEM,
"Name=login.y", "Value=8", ENDITEM,
LAST);
count=atoi(lr_eval_string("{check_1}"));
   if (count!=0) {
    lr_output_message("%d",count);
   }
   else{
    lr_output_message("not found");
   }

lr_end_transaction("login", LR_AUTO);
lr_start_transaction("book_ticket");
lr_think_time(72);

web_image("Search Flights Button",
"Alt=Search Flights Button",
"Snapshot=t3.inf",
LAST);

lr_think_time(17);
web_url("FormDateUpdate.class",
"URL=http://192.168.1.224:1080/WebTours/FormDateUpdate.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);
web_url("CalSelect.class",
"URL=http://192.168.1.224:1080/WebTours/CalSelect.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);

web_url("Calendar.class",
"URL=http://192.168.1.224:1080/WebTours/Calendar.class",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
EXTRARES,
"URL=YearMonthPanel.class", ENDITEM,
"URL=DayPanel.class", ENDITEM,
"URL=DateInfo.class", ENDITEM,
LAST);
lr_think_time(28);

web_submit_data("reservations.pl",
"Action=http://192.168.1.224:1080/WebTours/reservations.pl",
"Method=POST",
"RecContentType=text/html",
"Referer=http://192.168.1.224:1080/WebTours/reservations.pl?page=welcome",
"Snapshot=t4.inf",
"Mode=HTML",
ITEMDATA,
"Name=advanceDiscount", "Value=0", ENDITEM,
"Name=depart", "Value=Denver", ENDITEM,
"Name=departDate", "Value=12/31/2009", ENDITEM,
"Name=arrive", "Value=Denver", ENDITEM,
"Name=returnDate", "Value=12/2/2010", ENDITEM,
"Name=numPassengers", "Value=1", 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=53", ENDITEM,
"Name=findFlights.y", "Value=5", ENDITEM,
LAST);
lr_think_time(8);

web_submit_form("reservations.pl_2",
"Snapshot=t5.inf",
ITEMDATA,
"Name=outboundFlight", "Value=001;0;12/31/2009", ENDITEM,
"Name=reserveFlights.x", "Value=44", ENDITEM,
"Name=reserveFlights.y", "Value=6", ENDITEM,
LAST);
lr_think_time(5);
web_submit_form("reservations.pl_3",
"Snapshot=t6.inf",
ITEMDATA,
"Name=firstName", "Value=Joseph", ENDITEM,
"Name=lastName", "Value=Marshall", ENDITEM,
"Name=address1", "Value=234 Willow Drive", ENDITEM,
"Name=address2", "Value=San Jose/CA/94085", ENDITEM,
"Name=pass1", "Value=Joseph Marshall", ENDITEM,
"Name=creditCard", "Value=xiaojing", ENDITEM,
"Name=expDate", "Value=", ENDITEM,
"Name=saveCC", "Value=on", ENDITEM,
"Name=buyFlights.x", "Value=53", ENDITEM,
"Name=buyFlights.y", "Value=10", ENDITEM,
LAST);
lr_end_transaction("book_ticket", LR_AUTO);
lr_start_transaction("logof");
lr_think_time(80);
web_url("welcome.pl",
"URL=http://192.168.1.224:1080/WebTours/welcome.pl?signOff=1",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.168.1.224:1080/WebTours/nav.pl?page=menu&in=flights",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
lr_end_transaction("logof", LR_AUTO);
return 0;
}

ermine 发表于 2009-12-25 11:48:05

脚本好长。。。
你应该是用的第一个录制方式吧,describinguser action的
你可以看一下用jojo1登录的时候,有没有登录成功。
如果没有登录成功,web_image("Search Flights Button",
"Alt=Search Flights Button",
"Snapshot=t3.inf",
LAST);
这段就会找不到图片。

PS:错误显示的是在45行,你可以把脚本在分拆一下,确认是哪里的问题。
页: [1]
查看完整版本: LR脚本加入check_text函数后报错