/// <summary> /// </summary> /// <param name="tree"></param> /// <param name="allRowsExpression"> /// 接受如下格式: /// A/B;A/B/C;!A/C;!A /// /// !表示取消该行 /// 多行使用 ; 分隔。 /// 行内层级使用 / 作为分隔符,如果数据中有此字符,则可以使用 $ 来分隔。 /// </param> /// <returns></returns> public static WpfTreeItem 择行(this WpfTree tree, string allRowsExpression) { var rowPathes = allRowsExpression.SplitBy(";"); //由于 WinUIA 的速度太快,需要一定的时间来等待控件生成。 Thread.Sleep(100); WpfTreeItem row = null; foreach (var rowPath in rowPathes) { if (rowPath[0] == '!') { row = tree.行(rowPath.Substring(1)); var pattern = (row.NativeElement as WinUIA.AutomationElement) .GetCurrentPattern(WinUIA.SelectionItemPattern.Pattern) as WinUIA.SelectionItemPattern; pattern.RemoveFromSelection(); //WpfTreeItem 不支持 //row.Selected = false; } else { row = tree.行(rowPath); row.Selected = true; } } return(row); }
public void ClickOnCreateNewTestClass() { WpfControl installedDatagrid = new WpfControl(newprojectwindow); installedDatagrid.SearchProperties[WpfControl.PropertyNames.ControlType] = "DataItem"; installedDatagrid.SearchProperties[WpfControl.PropertyNames.AutomationId] = "Installed"; WpfExpander expand = new WpfExpander(installedDatagrid); WpfTree installedTreeView = new WpfTree(expand); installedTreeView.SearchProperties.Add(WpfTree.PropertyNames.AutomationId, "Installed"); WpfTreeItem tempTreeItem = new WpfTreeItem(installedTreeView); tempTreeItem.SearchProperties.Add(WpfTreeItem.PropertyNames.AutomationId, "Templates"); WpfTreeItem visualCtreeItem = new WpfTreeItem(tempTreeItem); visualCtreeItem.SearchProperties.Add(WpfTreeItem.PropertyNames.AutomationId, "Visual C#"); expand.Expanded = true; WpfTreeItem testTreeItem = new WpfTreeItem(visualCtreeItem); testTreeItem.SearchProperties.Add(WpfTreeItem.PropertyNames.AutomationId, "Test"); Mouse.Click(testTreeItem); }
/// <summary> /// ClickDebugOutput /// </summary> public void ClickDebugOutput() { #region Variable Declarations WpfTree uIItemTree = this.UIWarewolfWindow.UIOutputCustom.UIDebugOutputCustom.UIItemButton.UIItemTree; #endregion // Click first tree next to '+' button Mouse.Click(uIItemTree, new Point(103, 88)); }
/// <summary> /// Tells if a TreeView is empty or not. /// </summary> public static bool IsEmpty(this WpfTree tree) { if (tree == null) { throw new ArgumentNullException("tree"); } return(tree.Nodes.Count == 0); }
public static WpfTreeItem 择行(this WpfTree tree, int rowIndex) { var item = tree.Find <WpfTreeItem>(); item.SearchProperties[WpfTreeItem.PropertyNames.Instance] = (rowIndex + 1).ToString(); item.SearchConfigurations.Add(SearchConfiguration.ExpandWhileSearching); item.Selected = true; return(item); }
public static WpfTreeItem 当前行(this WpfTree tree) { foreach (WpfTreeItem row in tree.Nodes) { if (row.Selected) { return(row); } } throw new UIAutomationException("当前行没有返回值:Grid 没有选择行"); }
/// <summary> /// Counts the servers. /// </summary> /// <returns></returns> public int CountServers() { WpfTree uITvExplorerTree = UIBusinessDesignStudioWindow.UIExplorerCustom.UINavigationViewUserCoCustom.UITvExplorerTree; return(uITvExplorerTree.GetChildren().Count); }
/// <summary> /// Returns the root element of a WpfTree that has the specified name /// </summary> /// <param name="parent">The tree control</param> /// <param name="name">The name of the root element to look for</param> /// <returns>A <see cref="WpfTreeItem"/> that represents the found root element</returns> /// <exception cref="InvalidOperationException">The tree control does not have a root element with specified name, or it contain more than one</exception> public static WpfTreeItem GetChild(this WpfTree parent, string name) { return(GetChild(parent.Nodes, name)); }
/// <summary> /// /// </summary> /// <param name="tree"></param> /// <param name="path">使用 / 作为分隔符,如果数据中有此字符,则可以使用 $ 来分隔。</param> /// <returns></returns> public static WpfTreeItem 行(this WpfTree tree, string path) { string[] pathes = null; if (path.Contains("$") && path.Contains("/")) { pathes = path.SplitBy("$"); } else { pathes = path.SplitBy("/"); } if (pathes.Length > 0) { tree.Find(); WpfControl parent = tree; for (int i = 0, c = pathes.Length; i < c; i++) { var title = pathes[i]; //方案一 //var nodes = GetNodes(parent); //for (int j = 0, c2 = nodes.Count; j < c2; j++) //{ // var node = nodes[j] as WpfTreeItem; // if (node.Name == title) // { // if (i < c - 1) { node.Expanded = true; } // parent = node; // break; // } //} //方案二 //var node = parent.Find<WpfTreeItem>(title); //node.SearchConfigurations.Add(SearchConfiguration.ExpandWhileSearching); //node.Find(); //if (i < c - 1) { node.Expanded = true; } //parent = node; //方案三 var node = parent.Find <WpfTreeItem>(title); if (i < c - 1) { //由于 WinUIA 的速度太快,需要一定的时间来等待控件生成。 Thread.Sleep(100); var pattern = (node.NativeElement as WinUIA.AutomationElement) .GetCurrentPattern(WinUIA.ExpandCollapsePattern.Pattern) as WinUIA.ExpandCollapsePattern; pattern.Expand(); } parent = node; } if (parent is WpfTreeItem) { return(parent as WpfTreeItem); } } throw new UIAutomationException("没有找到对应的行:" + path); }
public UITestControlCollection GetOutputWindow() { WpfTree debugOutputControlTree = GetOutputTree(); return(debugOutputControlTree.Nodes); }