简体   繁体   English

不同版本的Windows上的UI自动化的AutomationId不一致

[英]UI Automation's AutomationId inconsistency on different versions of windows

I'm working on automating an application using UI Automation framework (.net 4.6.1). 我正在使用UI自动化框架(.net 4.6.1)自动化应用程序。

When inspecting the application using Visual UI Automation Verify i'm able to see the value of AutomationId properties. 使用Visual UI Automation Verify应用程序时,我可以看到AutomationId属性的值。

I have written a small automation script in C# (wpf) 我已经用C#(wpf)编写了一个小型自动化脚本

When I execute my automation script on windows 7, all works fine. 当我在Windows 7上执行自动化脚本时,一切正常。

When I try it on windows 10, all the AutomationId values are string empty. 在Windows 10上尝试时,所有AutomationId值均为空字符串。

Sample code: 样例代码:

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

This sample returns null, because it cannot find an element with myAutomationId value, when I explored all the children of AutomationElement.RootElement I found that the AutomationId values are empty (unlike what i see on Visual UI Automation Verify , and unlike what i get when running on windows 7) 此示例返回null,因为当我浏览AutomationElement.RootElement所有子级时,它找不到具有myAutomationId值的元素,我发现AutomationId值是空的(这与我在Visual UI Automation Verify上看到的不同,并且与当在Windows 7上运行)

Is there something i'm missing about AutomationId properties? 我对AutomationId属性缺少什么? or about how UI Automation framework runs on windows 10? 或关于UI自动化框架如何在Windows 10上运行?

Edit: 编辑:

I have noticed that when I loop through the child elements, I have found that some of them have an AutomationId that has a value of the NativeWindowHandle.. why is that?? 我注意到,当我遍历子元素时,我发现其中的一些元素具有一个AutomationId,其值为NativeWindowHandle的值。为什么?

Edit 2: 编辑2:

I have tried a very wide range of UI Automation dlls with multiple versions, none of was able to even find the application on windows 10. 我尝试了范围广泛的具有多个版本的UI自动化dll,但没有一个甚至无法在Windows 10上找到该应用程序。

Same thing goes for TestStack.White (doesn't work on windows 7 either). TestStack.White (在Windows 7上也不起作用)。

The UIA which works fine is UIAutomationClient.dll (+ UIAutomationTypes.dll if needed) 可以正常工作的UIA是UIAutomationClient.dll (如果需要,可以添加UIAutomationTypes.dll)

It uses Automation interfaces directly : 它直接使用自动化接口:

IUIAutomation uiautomation = new CUIAutomation();

and so on... 等等...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM