我在 XUnit 之上使用 FlaUI 进行测试,但 ComboBox 似乎不起作用。 我能够检索 ComboBox 对象,但它没有任何项目,并且 Select() 也不起作用。 我错过了什么?
有代码片段:
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
我最终创建了 ComboBox (FlaUI) 的扩展。这里的关键是使用
ExpandCollapsePattern
来操作 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;
}