0

I am using FlaUI on top of my XUnit to do the test, but the ComboBox doesn't seem to work. I was able to retrieve the ComboBox object, but it does not have any Items and Select() doesn't work either. What am I missing?

there's code snippet:

ComboBox box = createWOForm.ComboRoutingCode; // box returns the object
box.Focus();
int i = box.Items.Count(); // not Items...yes, I have visually check the UI...the ComboBox has items

enter image description here

Johnny Wu
  • 1,297
  • 15
  • 31

1 Answers1

0

I ended up create an extension to the ComboBox (FlaUI)...the key here is you have to use the the ExpandCollapsePattern to manipulate the UI:

internal static bool SelectItem(this ComboBox combo, string displayToSelect)
{
  IExpandCollapsePattern pattern = combo.Patterns.ExpandCollapse.Pattern;
  pattern.Expand();

  ComboBoxItem selectedItem = combo.Select(displayToSelect);

  return selectedItem != null;
}
Johnny Wu
  • 1,297
  • 15
  • 31