QTP Script for Combo Box Control

QTP Script for Combobox



In combo box items index start from 0

1.Script for selecting an item from combobox using its value

Window("Flight Reservation").WinComboBox("Fly From:").Select “Frankfurt”



2. Script for selecting an item from combobox using its index

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

1 indicates second item in combobox(0 for 1st item).

3.Script to get total items count of combobox

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

output will be 10.

4.Script to get value of selected item

selecteditem=Window("Flight Reservation").WinComboBox("Fly From:").GetSelection
Msgbox selecteditem

Output will be Frankfurt

5.Script to get all items(one by one) from combobox

count = Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox count
For i = 0 to count-1
item =Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
Msgbox item
Next

Output -- single item will be displayed in messagebox
Total 10 message boxes will be displayed one after other.

6.Script to get names(content) of all items(at a time) from combobox

Content = Window("Flight Reservation").WinComboBox("Fly From:").GetContent
Msgbox Content

Output will be
Denver
Frankfurt
London
Los Angeles
Paris
Portland
San Francisco
Seattle
Sydney
Zurich

All items in one messagebox.

Data Driven Testing
SQL Queries Collection
QTP Script for Connecting to Database
QTP Script for Textbox Control
QTP Script for Checkbox Control
QTP Script for Button Control
QTP Script for RadioButton Control

1 comment:

Anonymous said...

Nice post, thanks.
And what about handling Virtual object list? For object, that is not recognized by QTP?

Thanks

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge