【发布时间】:2011-02-09 20:38:52
【问题描述】:
我正在尝试使用 MSFT 提供的 UI-Automation 框架测试 WPF 应用程序。编写了一些 powershell 脚本,它们调用为操纵应用程序的可视控件而创建的 cmdlet。
我的应用程序中有一个 DropDown,它有一个条目“DropDownEntry”。在我的 cmdlet 中,我正在尝试执行以下操作:
AutomationElement getItem = DropDown.FindFirst(TreeScope.Descendants,
new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty,ControlType.ListItem),
new PropertyCondition(AutomationElement.NameProperty, "DropDownEntry",PropertyConditionFlags.IgnoreCase)));
上面给定的 sn-p 在执行时返回“null”,这基本上意味着上面给定的逻辑无法找到我的下拉条目。
谁能告诉我为什么会发生这种情况?我检查了我的控件的名称和值。一切似乎都井然有序。我不确定为什么会发生这种情况。任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: c# wpf testing powershell ui-automation