51Testing软件测试论坛

标题: 求高手指点:利用随机数选择WinList中项时总出现运行错误 [打印本页]

作者: ARCHANGEL4    时间: 2016-2-21 16:13
标题: 求高手指点:利用随机数选择WinList中项时总出现运行错误
刚开始学习UFT自动化测试,练习 订票系统 测试的过程中总出现如下的运行错误,点击“重试”几次有时候就能往下进行了,麻烦高手指点到底是哪里出现了错误,谢谢!
脚本内容如下:
  1. Dim itemCount

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

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

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

  16. 'Check
  17. Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
  18. Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DataTable("Name",dtLocalSheet)
  19. Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
  20. itemCount = Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").GetROProperty("items count")
  21. Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select RandomNumber(0,itemCount)
  22. Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click
复制代码
出错时状态如下:

作者: ARCHANGEL4    时间: 2016-2-22 09:04
没人气啊.. 自己顶一顶
作者: 蓝色忧郁38    时间: 2016-2-22 10:48
我不是高手
作者: 赵佳乐SMILE    时间: 2016-2-22 17:19
1.确定一下 WinList("Flight No.") 在对象库中
2.确定一下 Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DataTable("Name",dtLocalSheet) 能取到客户名
3.确定一下订单是存在的
作者: 赵佳乐SMILE    时间: 2016-2-22 17:19
简化了一下代码是可以的 跟随机数没关系


  1. Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
  2. Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set("kimi")
  3. Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
  4. itemCount = Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").GetROProperty("items count")
  5. Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select RandomNumber(0,itemCount)
复制代码





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