Selecting an Item from a Combobox

Ranorex Spy, Recorder, and Studio.
riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Selecting an Item from a Combobox

Post by riccardo » Mon May 03, 2010 8:44 pm

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();

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Selecting an Item from a Combobox

Post by Support Team » Tue May 04, 2010 12:24 pm

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
.
Image

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Selecting an Item from a Combobox

Post by riccardo » Tue May 04, 2010 5:01 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Selecting an Item from a Combobox

Post by Support Team » Wed May 05, 2010 10:02 am

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
.
Image