Hello,
I'm facing problem in Combobox Item selection.
The application under test is developed using VB6.0. I can able to spy combo boxes without any issues or conflicts. But the problem is it always gives the item collection count as 0.
For selecting an item I’ve to do like below:
//Code Snippet
Ranorex.ListItem ComboBoxListItem;
bool bItemFound = combo.TryFindSingle<ListItem>("//item[@text~'text_to_select']",out ComboBoxListItem);
if (bItemFound && ComboBoxListItem != null)
{
ComboBoxListItem.Click();
}
Is there any way to get the Item Collection of Visual Basic 6.0 Combo?
ComboBox Items Collection count is 0 for VB6 combo box.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: ComboBox Items Collection count is 0 for VB6 combo box.
Hi,
Please try to use
Regards,
Markus
Ranorex Support Team
Please try to use
".//item[@text~'text_to_select']"isntead of
"//item[@text~'text_to_select']"maybe Ranorex takes to long to find the specific elements if you use the "//", exceeds the timeout. Therefore use the ".//", the difference is that with the dot Ranorex searches for all the descendants of the current element, in your case of the combo element; whereas "//" searches from the very root of the element tree.
Regards,
Markus
Ranorex Support Team
Re: ComboBox Items Collection count is 0 for VB6 combo box.
Hi Markus,
Appreciate your answer. I changed the code as per your suggestion to select an item and it works. But my original question was : Why am I not getting the "Items" Property collection of comboBox adapter? For your information I am attaching a document which is having screen shots that shows the combobox which I spyed and also showing the code which I wrote to access the Items Collection, with description.
I am using Ranorex Version 3.0.2.
Regards,
Mohan
Appreciate your answer. I changed the code as per your suggestion to select an item and it works. But my original question was : Why am I not getting the "Items" Property collection of comboBox adapter? For your information I am attaching a document which is having screen shots that shows the combobox which I spyed and also showing the code which I wrote to access the Items Collection, with description.
I am using Ranorex Version 3.0.2.
Regards,
Mohan
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: ComboBox Items Collection count is 0 for VB6 combo box.
Hi,
Did you try instant tracking on the listitems of the combobox?
How to use Instant Tracking
If not please try it and for sure you will find a list with your items in it. The behavior of a combobox depends on the technology you use. Sometimes you can access the items directly under the control and sometimes you have the behavior above.
BTW, Ranorex 3.0.5 is released and it is very recommended to upgrade to this version.
http://www.ranorex.com/download/Ranorex-3.0.5.exe
Regards,
Peter
Ranorex Team
Combobox Items are very special indeed. In most cases the collection of the list items is nested directly under the host, therefore you need the instant tracking of Ranorex Spy.mohan wrote: Why am I not getting the "Items" Property collection of comboBox adapter?
Did you try instant tracking on the listitems of the combobox?
How to use Instant Tracking
If not please try it and for sure you will find a list with your items in it. The behavior of a combobox depends on the technology you use. Sometimes you can access the items directly under the control and sometimes you have the behavior above.
BTW, Ranorex 3.0.5 is released and it is very recommended to upgrade to this version.
http://www.ranorex.com/download/Ranorex-3.0.5.exe
Regards,
Peter
Ranorex Team
Re: ComboBox Items Collection count is 0 for VB6 combo box.
I got the solution but I did not try "instant tracking". The combo Box Item collection is populated with Items only when it is Visible in UI. If I click on the combo and then checks the Count then I’m getting the collection. The code is something like below:
objShipment.FormShipment.cmbFrom.Click();
if (objShipment.FormShipment.cmbFrom.Items.Count > 0)
objShipment.FormShipment.cmbFrom.Items[2].Click();
The above behaviour exists with Microsoft Combo box as well.BTW, thanks for supporting all the way to reach the solution.
objShipment.FormShipment.cmbFrom.Click();
if (objShipment.FormShipment.cmbFrom.Items.Count > 0)
objShipment.FormShipment.cmbFrom.Items[2].Click();
The above behaviour exists with Microsoft Combo box as well.BTW, thanks for supporting all the way to reach the solution.