使用 TestStack.White 访问 Infragistics UI 组件

Accessing Infragistics UI components with TestStack.White

我有一个 C# WinForms 应用程序,它使用了几个 Infragistics 组件,包括网格、状态栏等等。

我正在尝试使用 TestStack.White 自动执行 UI 测试:到目前为止,我已经成功地与常规 .net 组件交互。

我正在使用可视化 UI 自动化验证工具来探索应用程序和 locate/access 所需的 UI 组件。我需要在 UltraStatusBar 中访问突出显示的超链接的文本。

以下是我使用的C#代码。我可以成功地从主 window 中获取包含 UltraStatuBar 的面板,并从该面板中获取状态栏本身,但不知何故我无法访问 UltraStatusBar 中的 UI 组件。

有什么提示吗?

您似乎使用了 UIA Verify 2.0,它向您展示了使用 UIComWrapper 可以看到的内容。 White 使用 MS UI Automation 没有 UICom.

可能的解决方案 - 尝试通过本机 MS UI 自动化找到控件,如果是白人问题

var elementsCollection = statusBar.AutomationElement.FindAll(TreeScope.Children, Condition.TrueCondition);
     foreach (AutomationElement element in elementsCollection)
     {
         if (element.Current.AutomationId.Contains("lblFileName"))
         {
             //do what you need
         }
     }

您是否尝试过使用 White 的 UIAComWrapper 分支?我发现如果没有 MS Automation 3.0(这是 UIAComWrapper 包装的),许多 Infragistics 控件无法访问。