Selecting values in combo box

Oct 21, 2010 at 9:35 AM

hi all,

  I have three combo boxes and a text box in the application I'm automating, I am trying to set value to one text box and select values in those combo boxes as below,

webFormName.SetValue("New Value");  //Textbox

Owner.SetValue("Cathy Green");//Textbox

Audience.Select(1); //Combo box

Status.Select(1);//Combo box


Some time some of these steps are missing, it may assign or not assign values to text boxes or some time it may select or not select values from dropdown box, I guess it has something to do with the execution speed. Can any one help me in getting it to work properly ? Most of times it sets values to first textbox ( webFormName) and next 3 statements will execute properly but no values will be selected in combo boxes.


Thanks in advance.

Oct 21, 2010 at 9:59 AM



set values in Textboxes should not fail, you can write a small function, which try to set the value more times (this will increase the stability of the test).

In some cases the dialog is not completly ready so maybe wait till the element you want to use is enabled and visible.

You can try to use Thread.Sleep() to wait a short time, but better is you want for control depending things like visibility or item is enabled/disabled, and so on.


The comboxBoxes is a known problem, for fast machines


I use an own function to get this stable, its something like that



Predicate predicate = new Predicate(p=>p.Name == "item name");

Thread.Sleep(100); // be sure the drop down opens (for fast machines)

   ListItem item = comboBox.Items.Where(predicate).First();


You can verify with comboBox.GetSelectedItemText(), that the item is selected (maybe more tries to set the value will be helpfull)


hope that helps

Oct 21, 2010 at 10:29 AM

Hi Throndorin

Thanks for the response, I didn't include one more thing, The combo box i'm trying to select value from is, too slow. When I click on the drop down it takes some time to display values inside id (Probably takes time to populate). I will try the way you have suggested. Thanks a lot. I'll come back if I have still more doubt.

May 6, 2011 at 3:25 PM
Edited May 6, 2011 at 3:34 PM


I see this is an old thread but figured I may as well post my solution that I have found today. I saw quite a few discussions on the ComboBox issue today so I'm sure more people in future could benefit from my solution. So far it seems stable and has worked every time. It does not have any Sleep(x) command so should work on all machine speeds I would assume. Below is a snippet of some code where I am selecting an item in a ComboBox : 


if (foundControl is WPFComboBox)
     var comboBoxItem = ((WPFComboBox)foundControl).Items.Where(p => p.AutomationElement.Current.Name == "ItemText").First();
     var selPat = comboBoxItem.AutomationElement.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
     if(selPat != null)
Jan 22, 2013 at 5:04 AM

Try using the below code-

ControlType c = ControlType.ComboBox;
           ComboBox combobox = (ComboBox)combowindow.Get(SearchCriteria.ByControlType(c).AndIndex(index));

White.Core.UIItems.ListBoxItems.ListItem item;
               item = combobox.Items.Single(thisItem => thisItem.Text == combovalue);
               if (!item.Visible)

Feb 9, 2013 at 6:44 AM
The underlying issue has been fixed in

The next update I push to NuGet will have the fix included.

You can grab the nightly build from