QTP随机选择下拉列表的值

以下为获取下拉列表的随机值方法,可任选其一:

Dialog("Login").WinEdit("Agent Name:").Set "admin"

Dialog("Login").WinEdit("Password:").Type "MERCURY"

Dialog("Login").WinEdit("Password:").SetSecure "4b29c253db2a7749f082713f2b95c0f7f5583f35"

Dialog("Login").WinEdit("Password:").Type micReturn

Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"

方法一:

a1=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("items count")

Window("Flight Reservation").WinComboBox("Fly From:").Select Randomnumber(0,a1-1)

 

方法二:

a1=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount

Window("Flight Reservation").WinComboBox("Fly From:").Select Randomnumber(0,a1-1)

 

方法三:

a1=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("items count")

Dim a1,a2,a3

Function getlist(i)

       Randomize

       getlist=Randomnumber(0,i)

 End Function

a2= getlist(a1-1)

a3=Window("Flight Reservation").WinComboBox("Fly From:").GetItem(a2+1)

Window("Flight Reservation").WinComboBox("Fly From:").Select a3

 

方法四:

Dim a1,a2

Function getlist(i)

       Randomize

       getlist=Randomnumber(0,i)

 End Function

a1=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("items count")

a2= getlist(a1-1)

Window("Flight Reservation").WinComboBox("Fly From:").Select a2

 

b1=Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("items count")

Window("Flight Reservation").WinComboBox("Fly To:").Select Randomnumber(0,b1-1)

Window("Flight Reservation").WinButton("FLIGHT").Click

c1=Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItemsCount

Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select Randomnumber(0,c1-1)

Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

Window("Flight Reservation").WinEdit("Name:").Set "llyy"

Window("Flight Reservation").WinEdit("Tickets:").SetSelection 0,1

Window("Flight Reservation").WinEdit("Tickets:").Set "2"

Window("Flight Reservation").WinRadioButton("Business").Set

Window("Flight Reservation").WinButton("Insert Order").Click

Window("Flight Reservation").Close

posted @ 2009-12-17 14:05  小e  阅读(2065)  评论(0编辑  收藏  举报