51Testing软件测试论坛

标题: 飞机订票系统不能识别对象 [打印本页]

作者: 熙熙0506    时间: 2014-10-28 17:07
标题: 飞机订票系统不能识别对象
代码如下:Window("Flight Reservation").ActivateWindow("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "121214"
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("Fly_From", dtGlobalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("Fly_To", dtGlobalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
Countall = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItemsCount
RandomNum = RandomNumber(0,Countall)
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select RandomNum
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "vivi"
Window("Flight Reservation").WinButton("Insert Order").Click
wait(8)
RecordNo = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
DataTable("Order_No",dtGlobalSheet)=RecordNo
Dim flyfrom,flyto,flightno
flyfrom=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("regexpwndtitle")
flyto=Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("regexpwndtitle")
flightno=Window("Flight Reservation").WinEdit("Flight No:").GetROProperty("regexpwndtitle")
DataTable("flyfrom",dtGlobalSheet)=flyfrom
DataTable("flyto",dtGlobalSheet)=flyto
DataTable("flightno",dtGlobalSheet)=flightno
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"                                                        '   勾选Customer Name
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "vivi"
wait(3)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click         
Dim countx                                                                                                                                                                         '   定义一个变量
countx = Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").GetROProperty("items count")'    改变量可以获取最新的动态查询结果的个数
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select (countx)       
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click                                '在查找出来的结果中选择第一项
Window("Flight Reservation").WinComboBox("Fly From:").Check CheckPoint("Fly From:")
Window("Flight Reservation").WinComboBox("Fly To:").Check CheckPoint("Fly To:")
Window("Flight Reservation").WinEdit("Order No:").Check CheckPoint("Order No:")

红色部分出现:
Cannot identify the specified item of the Flight No. object. Confirm that the specified item is included in the object's item collection.

Line (31): "Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select (countx)".

的错误。
我试过直接用
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select (1)和
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select 1
也能获取countx的值,求助,是前面那行的countx获取错误了吗?







作者: 赵佳乐SMILE    时间: 2014-10-29 09:56
Select  的下标是不是从0开始的  改成.Select (countx-1) 试试     
作者: 熙熙0506    时间: 2014-10-30 09:41
赵佳乐SMILE 发表于 2014-10-29 09:56
Select  的下标是不是从0开始的  改成.Select (countx-1) 试试

恩恩~~可以了~学习了~




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2