Page 1 of 1

Selecting an Item from a Combobox

Posted: Mon May 03, 2010 8:44 pm
by riccardo
I am trying to select an item from a combobox as described in the help. The path for the combobox is correct and will be tracked by ranorex.

But with my code the list item won't be selected. The variable s_username has the correct value during runtime and the value exists in the list.

Any ideas?

Code: Select all

Ranorex.ComboBox combobox = "/form[@controlname='mdiXCanWSAnalyzer']/element[@controltypename='MdiClient']/form/container/container[@controlname='panel1']/element[@controlname='ucboUserName']/combobox/combobox";			
			ListItem lst_userItem = combobox.FindSingle<ListItem>("list/listitem[@accessiblename='"+s_username+"']");
			lst_userItem.Click();

Re: Selecting an Item from a Combobox

Posted: Tue May 04, 2010 12:24 pm
by Support Team
Hi!

I think at runtime the items of the combobox don't exist until they are visible. So try before you select an item of the combobox to open the box so the items will be generated (get state visible true) by element and Ranorex should be able to select one item.
Also see following link for a combobox example
http://www.ranorex.com/support/user-gui ... html#c1875

Regards,
Peter
Ranorex Support Team

Re: Selecting an Item from a Combobox

Posted: Tue May 04, 2010 5:01 pm
by riccardo
Hi Peter

I followed the example already the first time I have created it. The combobox is known and will be opened, but afterwards the mouse just jumps on top-left of the screen. I also tried to record it, the same happens when replaying that one.

Re: Selecting an Item from a Combobox

Posted: Wed May 05, 2010 10:02 am
by Support Team
Hi!

The mouse jumps on top-left of the screen, because Ranorex doesn't know the coordinates of this item. Please, use the Focus() method for this element before you try to click it. Then this will guarantee that the item is visible for Ranorex.
Ranorex.ComboBox combobox = "/form[@controlname='mdiXCanWSAnalyzer']/element[@controltypename='MdiClient']/form/container/container[@controlname='panel1']/element[@controlname='ucboUserName']/combobox/combobox";         
ListItem lst_userItem = combobox.FindSingle<ListItem>"list/listitem[@accessiblename='"+s_username+"']");

lst_userItem.Focus();
lst_userItem.Click();
Regards,
Peter
Ranorex Support Team