|
7#
楼主 |
发表于 2007-8-3 04:30:53
|
只看该作者
其实是我自己不细心!
这段代码有问题:
b = randomnumber(1,a)
window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("winid:=2001").Select b
select的是一个char串,而并不是一个number。所以执行不过去。还有一个我想说的就是winid这个属性最好不要用在描述性编程中。因为我今天又跑了N次后,发现没有这个属性了sdlkfj8 ,今天一看,出来了一个window id属性。sdlkfj5
后来我把代码改成如下:
a = window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").GetItemsCount
b = randomnumber(0,a-1)
c = window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").GetItem (b)
window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").Select c
就能顺利跑通了。
我是通过一个randomnumber实现在Flights Table中随机选取航班。这里我想说一下,randomnumber这个函数的起点是0,前面的代码中我也写错了,我从1开始的,当然会错误了。所以也提出来,希望大家能以我为戒。一定要细心。
我在调上面那段代码的时候也出现了一个很弱智的错误。属性“attached text”这个词组中,多加了一个空格。郁闷了N分钟,后来还是一个同学帮我看出来的,他是19期中的QTP高手。希望大家能多多交流,共同进步。
p.s.:6楼的是20期的吧?!我把我今天调的代码贴出来,还没完成,多多交流,交流!
systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
dialog("regexpwndtitle:=Login").Activate
dialog("regexpwndtitle:=Login").winedit("attachedtext:= Agent Name:").Set "admin"
dialog("regexpwndtitle:=Login").winedit("attachedtext:= Password:").Set "mercury"
dialog("regexpwndtitle:=Login").winbutton("nativeclass:=button","text:=OK").click
wait 5
window("regexpwndtitle:=Flight Reservation").ActiveX("progid:=MSMask.MaskEdBox.1").type "111111"
window("regexpwndtitle:=Flight Reservation").WinComboBox("attachedtext:=Fly From:").Select "London"
window("regexpwndtitle:=Flight Reservation").WinComboBox("attachedtext:=Fly To:").Select "Denver"
window("regexpwndtitle:=Flight Reservation").winbutton("regexpwndtitle:=FLIGHT").Click
a = window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").GetItemsCount
b = randomnumber(0,a-1)
c = window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").GetItem (b)
window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winlist("nativeclass:=ListBox","attached text:= From").Select c
window("regexpwndtitle:=Flight Reservation").dialog("regexpwndtitle:=Flights Table").winbutton("nativeclass:=Button","text:=OK").Click
window("regexpwndtitle:=Flight Reservation").winedit("nativeclass:=Edit","attached text:=Name:").Set "cc"
window("regexpwndtitle:=Flight Reservation").winedit("nativeclass:=Edit","attached text:=Tickets:").set "2"
d = randomnumber(1,3)
window("regexpwndtitle:=Flight Reservation").winradiobutton("nativeclass:=Button","index:="+cstr(d)).set |
|