ARCHANGEL4 发表于 2016-2-21 16:13:17

求高手指点:利用随机数选择WinList中项时总出现运行错误

刚开始学习UFT自动化测试,练习 订票系统 测试的过程中总出现如下的运行错误,点击“重试”几次有时候就能往下进行了,麻烦高手指点到底是哪里出现了错误,谢谢!
脚本内容如下:
Dim itemCount

'Book
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type DataTable("OrderDate", dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("FlyFrom",dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("FlyTo",dtLocalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click

If Window("Flight Reservation").Dialog("Flights Table").WinList("From").Exist Then
        itemCount = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("items count")
        Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select RandomNumber(0,itemCount)
        Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
End If

Window("Flight Reservation").WinEdit("Name:").Set DataTable("Name",dtLocalSheet)
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinButton("Button_2").Click

'Check
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DataTable("Name",dtLocalSheet)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
itemCount = 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 RandomNumber(0,itemCount)
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click出错时状态如下:

ARCHANGEL4 发表于 2016-2-22 09:04:15

没人气啊.. 自己顶一顶

蓝色忧郁38 发表于 2016-2-22 10:48:06

我不是高手:victory:

赵佳乐SMILE 发表于 2016-2-22 17:19:03

1.确定一下 WinList("Flight No.") 在对象库中
2.确定一下 Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DataTable("Name",dtLocalSheet) 能取到客户名
3.确定一下订单是存在的

赵佳乐SMILE 发表于 2016-2-22 17:19:43

简化了一下代码是可以的 跟随机数没关系


Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set("kimi")
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
itemCount = 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 RandomNumber(0,itemCount)
页: [1]
查看完整版本: 求高手指点:利用随机数选择WinList中项时总出现运行错误