(FlaUI) CombBox 没有 Items,Select() 不起作用

问题描述 投票:0回答:1

我在 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

enter image description here

flaui
1个回答
3
投票

我最终创建了 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;
}
© www.soinside.com 2019 - 2024. All rights reserved.