获取下拉值,这里以qtp自带的航班系统为例
Dialog("Login").WinEdit("Agent Name:").Set "t_cy"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "52a672c06f1014b113d76d3a4b2a40807ac5b872"
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Move 64,376
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "10022013"
'以上为录制的登录代码,下面将正式分析下拉框的取值
'fly from
itemscount=window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("items count") ’获取下拉框的值数量
'msgbox(itemscount)
For i=0 to itemscount -1 '循环取值,从0开始
window("Flight Reservation").WinComboBox("Fly From:").Select i '依次选中下拉框的值
'这样,下拉框的值就取值完毕了。
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").Close
Next