not able to select an item in Combobox

Oct 26, 2012 at 5:58 AM

not able to select an item in combobox. given below is Combobox select code and properties:

 var comboBox = win.Get<White.Core.UIItems.ListBoxItems.ComboBox>(SearchCriteria.ByAutomationId("cmbSupplier"));
            if (comboBox != null)
            {
                Thread.Sleep(2000);
                comboBox.Select("ABC");
                Console.WriteLine("Combobox Selected");
            }
            else
            {
                Console.WriteLine("Combobox not Found");
            }

  Identification
    ClassName: "WindowsForms10.Window.b.app.0.33c0d9d"
    ControlType: "ControlType.ComboBox"
    Culture: "(null)"
    AutomationId: "cmbSupplier"
    LocalizedControlType: "combo box"
    Name: "A.P. Moeller"
    ProcessId: "72264 (VeManagement.Client)"
    RuntimeId: "42 13763252"
    IsPassword: "False"
    IsControlElement: "True"
    IsContentElement: "True"

Oct 26, 2012 at 7:31 AM

Hi

try the following

 

var comboBox = win.Get<White.Core.UIItems.ListBoxItems.ComboBox>(SearchCriteria.ByAutomationId("cmbSupplier"));
            if (comboBox != null)
            {
                comboBox.Click();
                win.Title.Click();
                //Thread.Sleep(2000);
                comboBox.Select("ABC");
                Console.WriteLine("Combobox Selected");
            }
            else
            {
                Console.WriteLine("Combobox not Found");
            }

 

If this don't work, try this

var comboBox = win.Get(SearchCriteria.ByAutomationId("cmbSupplier"));
if (comboBox != null)
{
ListItems items;
comboBox.Click();
win.Title.Click();
//Thread.Sleep(2000);
items = comboBox.Items;
ListItem item = items.Where(p=>p.Name=="ABC").First();
combBox.Click(); item.Select(); //or Click();
Console.WriteLine("Combobox Selected");
}
else
{
Console.WriteLine("Combobox not Found");
}
In some cases it might be helpful too use a loop and verify that the item exists (this might stable tests)

Jan 22, 2013 at 5:02 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 == valuetobesetincombobox);
               if (!item.Visible)
               {
                   combobox.Click();
               }
               item.Click();
              

Coordinator
Feb 9, 2013 at 6:44 AM
The underlying issue has been fixed in https://github.com/TestStack/White/pull/65

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

You can grab the nightly build from http://teamcity.ginnivan.net/viewType.html?buildTypeId=bt2