我正在使用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上运行时得到的)。
关于AutomationId
属性,我缺少什么东西吗?或者是关于UI自动化框架如何在windows 10上运行?
编辑:
我注意到,当我循环遍历子元素时,我发现其中一些元素有一个AutomationId,其值为NativeWindowHandle。那是为什么?
编辑2:
我尝试过多种版本的UI Automation,没有一个能在windows 10上找到应用程序。
TestStack.White
也是如此( windows 7也不起作用)。
发布于 2019-07-16 22:40:00
工作良好的UIA是UIAutomationClient.dll (如果需要的话+ UIAutomationTypes.dll )。
它直接使用自动化接口:
IUIAutomation uiautomation = new CUIAutomation();
等等..。
https://stackoverflow.com/questions/56832226
复制相似问题