c# - 在 MS Edge 浏览器的页面内找不到 UI 控件
问题描述
为客户的应用程序进行自动化测试 SSO 登录。应用程序使用授权页面打开默认浏览器 (MS Edge)。
我正在使用 MS UI 自动化来查找控件并采取行动。而且我还使用“Visual UI Automation verify”(VisualUIAVerifyNative)工具来检查控件。该工具完美地找到了我需要的一切。但我无法使用代码找到相同的元素。
我能够找到 Edge 窗口和一些控件,直到名为“m_webpageContent”的控件应该包含页面本身和其中的 Ui 控件。但是当我试图在其中找到元素时 - 我得到了空值。
var MainWindow = AutomationElement.RootElement.FindFirst(TreeScope.Descendants,
new AndCondition(
new PropertyCondition(AutomationElement.NameProperty, "Microsoft Edge"),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window)));
var TheLayout = MainWindow.FindFirst(TreeScope.Descendants,
new AndCondition(
new PropertyCondition(AutomationElement.AutomationIdProperty, "m_webpageContent"),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Group)));
var w = TheLayout.FindAll(TreeScope.Descendants,
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); // 0 elements
w = TheLayout.FindAll(TreeScope.Descendants,
new PropertyCondition(AutomationElement.FrameworkIdProperty, "MicrosoftEdge")); // 0 elements
我也尝试使用 TreeWalker 来遍历控件树,但它也没有帮助......
这里有什么问题?我还能做什么?
谢谢!
解决方案
找到了解决方案。我用来发现 UI 控件的工具使用UIAComWrapped.dll。当我在我的自动化项目中引用它时,它开始查找所有“MicrosoftEdge”控件。
推荐阅读
- javascript - 打开连接到跳转链接锚的手风琴面板
- python - 优化 POST 请求中的 CSV 文件处理(Django Rest Framework)
- ios - Firebase 方法返回未知错误
- typescript - 如何修复 TypeError: undefined is not an object (evalating '_config.Svg.G')
- java - MySQL 源代码文档中的 (1UL << 22) 是什么意思
- makefile - 调试无限期挂起的makefile
- node.js - 如何将 response.body 从请求模块功能中发送出去?
- reactjs - 在 reactjs 中设置状态时遇到问题
- apache-pig - Apache Pig,包括 DaysBetween 的端点
- time-series - 时间序列中的缺失数据