Get all Items in a ComboBox

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Get all Items in a ComboBox

Post by atom » Fri Feb 13, 2009 4:02 pm

Hiya

In my application i have a win32 combo box
I want to get a list of all available options in the combo drop down list

In Ranorex ive done:

Code: Select all

Dim objCombo as ranorex.combobox
Dim objItems as generic.list(of ranorex.listitems)

objCombo = "... xpath ..."
objItems = objCombo.Items
the problem is then objItems only contains the selected item, and not all available items.

We often validate that combo box items exist, so need to get a list of what options are available.

cheers

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Fri Feb 13, 2009 4:10 pm

What's the flavor of the combo box? You can see the flavor name of an element in the Detail tab of RanorexSpy.

It could be that the combo box items are generated by the control when the list is opened for the first time.

Regards,
Alex
Ranorex Support Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Fri Feb 13, 2009 4:16 pm

Hiya,

On Detail tab of Spy tool i have:

- PreferredCapability = ComboBox[combobox]
- FlavorName = win32
- DropDownVisible = False

I noticed when i select different items, and click Refresh in SpyTool, i always get "SelectedItemIndex = 0"



[/img]

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Fri Feb 13, 2009 4:21 pm

Ok yeah i think your correct
Need to click on expand button first to display the drop down

Cheers

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Fri Feb 13, 2009 4:23 pm

Sorry, that's Win32 combo box specific. The item list is populated when you first open the drop down.

Regards,
Alex
Ranorex Support Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Fri Feb 13, 2009 4:35 pm

Cant seem to get my code to work though, I now have:

Code: Select all

Dim strComboPath as String = "......[@controlid='113']"
Dim objCombo As Ranorex.ComboBox
Dim objItems As Generic.List(Of ranorex.ListItem)
Dim objButton As ranorex.Button
                
objCombo = strComboPath
objButton = strComboPath & "/button"
   
objButton.Click
objItems = objCombo.Items
Surely its a fairly straight forward to do

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Fri Feb 13, 2009 5:00 pm

Have the same problem for a WinForms combo box also

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Feb 16, 2009 12:05 pm

You can only be sure that the combobox list elements exist when the combobox drop down list is visible. Whether the list elements exist even if the drop down is closed, depends on the underlying technology (i.e. flavor).

Regards,
Alex
Ranorex Support Team