遍历WinComboBox和Winlist对象值

上一篇 / 下一篇  2011-10-31 14:28:59 / 个人分类:QTP的学习研究

 在遇到WinComboBox和Winlist对象时,要想获取他们的值,可以使用WinComboBox对象和Winlist对象的GetItem方法和GetItemsCount方法分别获取值。
   语法如下:
   object.GetItem(Item):获取对象列表内容。
   object.GetItemsCount:获取对象列表内容的个数。
   如飞机订票系统中得获取起始地址、目的地和航班的数量的脚本在Expert view中可以使用如下脚本:
   Str_FlyFrom=Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i) '获取当前航班的起始地名称
   Str_FlyTo=Window("Flight Reservation").WinComboBox("Fly To:").GetItem(j) ‘获取当前航班的目的地名称
   Str_From=Window("Flight Reservation").Dialog("Flight Table").WinList("From")GetItem(k) '获取航班次数
 
  获取起始地、目的地和航班信息脚本在Expert View中的脚本:
  IntNumber_FlyFrom=Window("Flight Reservation").WinComboBox("Fly From:").GetItemCount '获取起始地个数
  IntNumber_FlyTo=Window("Flight Reservation").WinComboBox("Fly To:").GetItemCount '获取目的地个数
  IntNumber_From=Window("Flight Reservation").Dialog("Flight Table").WinList("From")GetItemCount '获取航班号
 

TAG:

 

评分:0

我来说两句

Open Toolbar