【问题标题】:UI Automation's AutomationId inconsistency on different versions of windowsUI Automation的AutomationId在不同版本的windows上不一致
【发布时间】:2019-11-11 21:46:00
【问题描述】:

我正在使用 UI 自动化框架 (.net 4.6.1) 自动化应用程序。

使用Visual UI Automation Verify 检查应用程序时,我能够看到AutomationId 属性的值。

我用 C# (wpf) 编写了一个小型自动化脚本

当我在 Windows 7 上执行自动化脚本时,一切正常。

当我在 Windows 10 上尝试时,所有 AutomationId 值都是空字符串。

示例代码:

AutomationElement.RootElement.FindFirst (
  TreeScope.Descendants, 
  new PropertyCondition(AutomationElement.AutomationIdProperty, myAutomationId)
);

此示例返回 null,因为它找不到具有 myAutomationId 值的元素,当我探索 AutomationElement.RootElement 的所有子项时,我发现 AutomationId 值是空的(与我在 Visual UI Automation Verify 上看到的不同,并且不像我在 Windows 7 上运行时得到什么)

我对@9​​87654327@ 属性有什么遗漏吗?或关于如何 UI 自动化框架在 Windows 10 上运行?

编辑:

我注意到,当我遍历子元素时,我发现其中一些元素的 AutomationId 具有 NativeWindowHandle 的值。这是为什么呢??

编辑 2:

我已经尝试了非常广泛的具有多个版本的 UI 自动化 dll,但都无法在 Windows 10 上找到该应用程序。

TestStack.White 也是如此(也不适用于 Windows 7)。

【问题讨论】:

    标签: .net windows automation ui-automation uia


    【解决方案1】:

    可以正常工作的 UIA 是 UIAutomationClient.dll(如果需要,还可以加上 UIAutomationTypes.dll)

    它直接使用自动化接口:

    IUIAutomation uiautomation = new CUIAutomation();
    

    等等……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 2010-11-02
      • 2018-03-07
      • 1970-01-01
      相关资源
      最近更新 更多