我正在自动化Windows应用程序。我试图在选项卡控件下访问窗格元素(具有文本框,组合框控件),但它不可访问。白色返回null。白/ UI自动化无法识别标签中的容器(窗格控件)
我尝试了其他技术,如UI自动化TreeWalker(Rawview,控制视图,内容视图),但没有什么帮助。
参考图像下面的链接: https://dl.dropboxusercontent.com/u/68446125/Tab.png https://dl.dropboxusercontent.com/u/68446125/General%20Pane.png
正如图1,标签控制是由白/ UI自动化正确检索,但子元素不会返回通用*面板,它的控制是不可访问(请参阅图2突出显示),第一个可访问的子元素是“常规*选项卡项目”。
奇怪的是,这些控件可以在Inspect.exe(在Windows SDK中)访问。我试过以下方法来检索控件,但通用*窗格永远不能通过白/ UI自动化访问。
var tab = Window.Get<Tab>(SearchCriteria.ByControlType(ControlType.Tab).AndByClassName("TwoPageControl")); // Tab control is retrieved properly
var pane = tab.GetElement(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*")); // this line returns NULL
var pane1 = revWindow.GetElement(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*")); // this line returns NULL
var pane2 = revWindow.Get<Panel>(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*"));// throws exception "Failed to get ControlType=pane,Name=General*,ControlType=pane"
尝试了Windows UI自动化代码,但没有运气。
System.Windows.Automation.Condition cd1 = new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Tab),
new PropertyCondition(AutomationElement.ClassNameProperty, "TwoPageControl"));
AutomationElement a = window.FindFirst(TreeScope.Descendants, cd1); // Tab control is returned properly here
TreeWalker rawViewWalker = TreeWalker.RawViewWalker;
AutomationElement cc = rawViewWalker.GetFirstChild(a); // General * Pane is not returned, instead General* Tab item is returned, though it's not the first child.
var cd = rawViewWalker.GetNextSibling(cc); // this returns next pane element available, not General * Pane.
请帮助我如何访问常规*窗格及其在选项卡控制下的儿童。任何帮助深表感谢。