Selecting Value in a ComboBox

Jun 20, 2011 at 10:55 AM

We have a windows client app having a custom activex control hosting a web page. The web page has a WinFormComboBox that we need to target as part of our automation script. The good news is, white does a decent job of identifying this control and also selects an appropriate value from the list. However there are instances when the correct value is not selected from the dropdown, I will try and explain this with the code snippet given below

White.Core.Application _lowis = White.Core.Application.Attach("LowisLauncher" );

List<White.Core.UIItems.WindowItems.Window > _lowiswindow = _lowis.GetWindows();

_lowiswindow[1].DisplayState =DisplayState.Maximized;

var lst = _lowiswindow[1].Get<White.Core.UIItems.ListBoxItems.WinFormComboBox>(SearchCriteria .Indexed(0));

lst.Enter("Modbus" ); // This works

lst.Enter("TI 305" ); // This works

lst.Enter("SaltCreek WellTest"); // This does not work and the list item selected is an item that starts with letter "T"

Jun 21, 2011 at 7:52 AM

We were able to find a workaround for this by implementing the following

listItemCount=200;  // identify the max items that you feel that list box can have

            var lst = _activeWindow.Get<White.Core.UIItems.ListBoxItems.WinFormComboBox>(SearchCriteria.Indexed(index)); // identify the list by index / other search criteria
            for (int i = 0; i < listItemCount; i++)

                lst.Enter(itemText.Substring(0,1)); // enter the first character of the string
                if (lst.SelectedItemText.ToLower() == itemText.ToLower()) // if the expected data matches that  of the item break