我正在尝试使用自动化在WinForms const creds = {
username: "user",
password: "pass"
}
function Keys(key) {
console.log(key);
return creds[key];
}
const usernameValue = Keys("username");
的实例中查找树项
我在一个过程中显示对话框,然后在另一个测试过程中调用以下对话框:
FolderBrowserDialog
var dlg = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Browse For Folder"));
var treectrl = dlg.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "SHBrowseForFolder ShellNameSpace Control"));
var treeview = treectrl.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "SysTreeView32"));
var item = treeCtrl.FindFirst(TreeScope.Descendants, new AndCondition(
new PropertyCondition(AutomationElement.NameProperty, "Desktop"),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TreeItem)));
,dlg
和treectrl
返回有效的treeview
,但是AutomationElements
最终还是item
,即使我使用Inspect应用程序,它将显示名称为“ Desktop”的项目作为树视图的直接子项。
当我尝试使用null
浏览树控件的子级时,我看到的只是滚动条及其子级。
要在shell树控件中找到树项,还需要做其他事情吗?