无法在MS Edge浏览器中找到页面内的UI控件

问题描述 投票:0回答:1

为客户的应用程序进行自动化测试SSO登录。应用程序使用授权页面打开默认浏览器(MS Edge)。

我正在使用MS UI Automation来查找控件和操作。而且我还使用“Visual UI Automation验证”(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来浏览控件树,但它也没有帮助......

这有什么不对?我还能做什么?

谢谢!

c# automation microsoft-edge ui-automation
1个回答
0
投票

找到了解决方案。我用来发现UI控件的工具使用UIAComWrapped.dll。当我在自动化项目中引用它时,它开始找到所有“MicrosoftEdge”控件。

© www.soinside.com 2019 - 2024. All rights reserved.