flaui

(FlaUI) CombBox does not have Items, Select() does not work


I am using FlaUI on top of my XUnit to unit 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?

Here's a code snippet:

ComboBox box = createWOForm.ComboRoutingCode;
box.Focus();
int i = box.Items.Count();

ComboBox object Properties


Solution

  • I ended up creating an extension to the ComboBox (FlaUI). The key here is to use 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;
    }