public void RightClickHelp(string serverName, string folderName, string projectName) { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } Point p = new Point(theControl.BoundingRectangle.X + 50, theControl.BoundingRectangle.Y + 5); Mouse.Move(p); Thread.Sleep(500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Thread.Sleep(500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Thread.Sleep(500); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Down}"); Keyboard.SendKeys("{Enter}"); }
public UITestControl GetActivity() { UITestControl control = VisualTreeWalker.GetChildByAutomationIdPath(Activity, "SmallViewContent", "DropPoint"); var uiTestControl = control.GetChildren()[0]; return(uiTestControl.FriendlyName == "Drop Activity Here" ? null : uiTestControl); }
/// <summary> /// Navigates to a Workflow Item in the Explorer, Right Clicks it, and clicks Properties /// </summary> /// <param name="serverName">The name of the server (EG: localhost)</param> /// <param name="serviceType">The name of the service (EG: WORKFLOWS)</param> /// <param name="folderName">The name of the folder (AKA: Category - EG: BARNEY (Or CODEDUITESTCATEGORY for the CodedUI Test Default))</param> /// <param name="projectName">The name of the project (EG: MyWorkflow)</param> public void RightClickProperties(string serverName, string folderName, string projectName) { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } Point p = new Point(theControl.BoundingRectangle.X + 50, theControl.BoundingRectangle.Y + 5); Mouse.Move(p); Playback.Wait(500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Playback.Wait(1500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Playback.Wait(1500); SendKeys.SendWait("{UP}"); Playback.Wait(100); SendKeys.SendWait("{ENTER}"); Playback.Wait(100); }
public void RightClickDeployProject(string folderName, string projectName, string serverName = "localhost") { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } Point p = new Point(theControl.BoundingRectangle.X + 50, theControl.BoundingRectangle.Y + 5); Mouse.Move(p); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Thread.Sleep(1500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Thread.Sleep(1500); SendKeys.SendWait("{DOWN}"); Thread.Sleep(100); SendKeys.SendWait("{DOWN}"); Thread.Sleep(100); SendKeys.SendWait("{ENTER}"); // Add some focus, and dleay to make sure everything is fine Thread.Sleep(2500); Mouse.Click(new Point(Screen.PrimaryScreen.WorkingArea.Width - 10, Screen.PrimaryScreen.WorkingArea.Height / 2)); Thread.Sleep(2500); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { foreach (TextBox tb in VisualTreeWalker.FindVisualChildren <TextBox>(this)) { var be = tb.GetBindingExpression(TextBox.TextProperty); if (be != null) { be.UpdateSource(); } } if (string.IsNullOrEmpty(((ViewModels.Clients)DataContext).CurrentClient.IdCode)) { MessageBox.Show("Tunniste ei voi olla tyhjä.", "Puuttuvia tietoja", MessageBoxButton.OK, MessageBoxImage.Stop); return; } if (string.IsNullOrEmpty(((ViewModels.Clients)DataContext).CurrentClient.Name)) { MessageBox.Show("Nimi ei voi olla tyhjä.", "Puuttuvia tietoja", MessageBoxButton.OK, MessageBoxImage.Stop); return; } try { ((ViewModels.Clients)DataContext).SaveCurrentClient(); } catch (Exception x) { Console.WriteLine(x.Message); MessageBox.Show("Tallennus epäonnistui." + Environment.NewLine + "Virhe: " + x.Message); } }
private void GetExplorerTree() { try { _explorerTree = VisualTreeWalker.GetControl( "UI_DocManager_AutoID", "Z91e998e0ee8c4f069cdab9d2cd3f544e", "Z306a8df47193448e9dd2228d905d49cd", "UI_ExplorerPane_AutoID", "Uia.ExplorerView", "UI_NavigationViewUserControl_AutoID", "UI_ExplorerTree_AutoID"); } catch (UITestControlNotFoundException) //_explorerTree = VisualTreeWalker.GetControlFromRoot(0, false, 0, "Uia.SplitPane", "Z306a8df47193448e9dd2228d905d49cd", "UI_ExplorerPane_AutoID", "Explorer", "TheNavigationView", "Navigation"); //if(_explorerTree == null) { _explorerTree = VisualTreeWalker.GetControl( "UI_DocManager_AutoID", "Zc30a7af8e0c54bb5bccfbea116f8ab0d", "Zf1166e575b5d43bb89f15f346eccb7b1", "Z3d0e8544bdbd4fbc8b0369ecfce4e928", "Explorer", "UI_ExplorerPane_AutoID", "Uia.ExplorerView", "UI_NavigationViewUserControl_AutoID", "UI_ExplorerTree_AutoID"); //_explorerTree = VisualTreeWalker.GetControlFromRoot(0, false, 1, "Uia.SplitPane", "Zf1166e575b5d43bb89f15f346eccb7b1", "Z3d0e8544bdbd4fbc8b0369ecfce4e928", "Explorer", "UI_ExplorerPane_AutoID", "Explorer", "TheNavigationView", "Navigation"); } }
public void DoubleClickOpenProject(string serverName, string folderName, string projectName, int waitAmt = 0) { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } if (theControl != null) { Point p = new Point(theControl.BoundingRectangle.X + 60, theControl.BoundingRectangle.Y + 7); Playback.Wait(50); Mouse.Click(p); Playback.Wait(150); try { Mouse.DoubleClick(p); // ReSharper disable EmptyGeneralCatchClause } catch // ReSharper restore EmptyGeneralCatchClause { // this darn double click keeps bombing out ;) } Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads; theControl.WaitForControlReady(); Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly; Playback.Wait(waitAmt); } }
/// <summary> /// Rights the click rename project. /// </summary> /// <param name="resourceName"></param> /// <param name="serviceType">Type of the service.</param> /// <param name="categoryName"></param> /// <param name="newName"></param> /// <param name="serverName"></param> public void RightClickRenameResource(string resourceName, string categoryName, string newName, string serverName = "localhost") { EnterExplorerSearchText(resourceName); UITestControl theControl = null; if (categoryName != "Unassigned" && categoryName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, categoryName, resourceName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, resourceName); } Point p = new Point(theControl.BoundingRectangle.X + 100, theControl.BoundingRectangle.Y + 5); Mouse.Move(p); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Playback.Wait(500); SendKeys.SendWait("{DOWN}"); Playback.Wait(50); SendKeys.SendWait("{DOWN}"); Playback.Wait(50); SendKeys.SendWait("{DOWN}"); Playback.Wait(50); SendKeys.SendWait("{ENTER}"); Playback.Wait(50); SendKeys.SendWait(newName); Playback.Wait(50); SendKeys.SendWait("{TAB}"); Playback.Wait(150); SendKeys.SendWait("{TAB}"); }
public void StoppingTimerStopsTimer() { var analyzer = new AnalyzeInvokeCountAnalyzer(); VisualTreeWalker walker = null; VisualTreeWalkerTimer timer = null; RunOnUIThread.Execute(() => { walker = new VisualTreeWalker(new Button(), analyzer); timer = new VisualTreeWalkerTimer(walker, 10); timer.Start(); }); RunOnUIThread.WaitMilliSeconds(300); Assert.IsTrue(analyzer.AnalyzeCount >= 1); var oldCount = 0; RunOnUIThread.Execute(() => { timer.Stop(); Logger.LogMessage("Analyzer count before stopping: " + analyzer.AnalyzeCount); oldCount = analyzer.AnalyzeCount; }); RunOnUIThread.WaitMilliSeconds(400); Logger.LogMessage("Analyzer count after stopping: " + analyzer.AnalyzeCount); Assert.IsTrue(analyzer.AnalyzeCount == oldCount); }
private bool ValidateResourceExists(string resourceName, string folderName, string serverName = "localhost") { try { EnterExplorerSearchText(resourceName); Playback.Wait(1000); UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, resourceName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, resourceName); } if (theControl == null) { return(false); } return(true); } catch (Exception) { return(false); } }
private List <UITestControl> GetDataGridRowChildList(int rowNumber, ViewType viewType) { UITestControl childByAutomationIDPath = VisualTreeWalker.GetChildByAutomationIdPath(GetView(viewType), "Table"); List <UITestControl> uiTestControlCollection = childByAutomationIDPath.GetChildren().Where(c => c.ControlType == ControlType.Row).ToList(); return(uiTestControlCollection[rowNumber].GetChildren().ToList()); }
public void DragActivityOnDropPoint(ToolType toolType) { UITestControl dropPoint = VisualTreeWalker.GetChildByAutomationIdPath(Activity, "SmallViewContent", "DropPoint"); var boundingRectangle = dropPoint.BoundingRectangle; ToolboxUIMap.DragControlToWorkflowDesigner(toolType, new Point(boundingRectangle.X + 10, boundingRectangle.Y + 10)); }
/// <summary> /// Drags the resource from the explorer to the active tab. /// </summary> /// <param name="tabToDropOnto">The tab to drop the resource onto.</param> /// <param name="resourceName">The name of the resource.</param> /// <param name="categoryName">The name of the category.</param> /// <param name="serviceType">Type of the service.</param> /// <param name="serverName">Name of the server (Will default to "localhost").</param> /// <param name="pointToDragTo">The point to drop the resource on the designer (Will default to just below the start node).</param> /// <param name="overrideDblClickBehavior">if set to <c>true</c> [override double click behavior].</param> public UITestControl DragResourceOntoWorkflowDesigner(UITestControl tabToDropOnto, string resourceName, string categoryName, string serverName = "localhost", Point pointToDragTo = new Point()) { if (pointToDragTo.X == 0 && pointToDragTo.Y == 0) { pointToDragTo = WorkflowDesignerUIMap.GetStartNodeBottomAutoConnectorPoint(tabToDropOnto); } EnterExplorerSearchText(resourceName); UITestControl theControl = null; if (categoryName != "Unassigned" && categoryName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, categoryName, resourceName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, resourceName); } Mouse.StartDragging(theControl); Playback.Wait(20); Mouse.StopDragging(pointToDragTo); Playback.Wait(100); UITestControl resourceOnDesignSurface = WorkflowDesignerUIMap.FindControlByAutomationId(tabToDropOnto, resourceName); int counter = 0; while (resourceOnDesignSurface == null && counter < 5) { Playback.Wait(1000); resourceOnDesignSurface = WorkflowDesignerUIMap.FindControlByAutomationId(tabToDropOnto, resourceName); Playback.Wait(500); counter++; } return(resourceOnDesignSurface); }
public void RightClickDeleteResource(string resourceName, string categoryName, string serverName) { EnterExplorerSearchText(resourceName); UITestControl theControl = null; if (categoryName != "Unassigned" && categoryName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, categoryName, resourceName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, resourceName); } Point p = new Point(theControl.BoundingRectangle.X + 100, theControl.BoundingRectangle.Y + 5); Mouse.Move(p); Playback.Wait(500); Mouse.Click(MouseButtons.Right, ModifierKeys.None, p); Playback.Wait(1000); SendKeys.SendWait("{DOWN}"); Playback.Wait(100); SendKeys.SendWait("{DOWN}"); Playback.Wait(100); SendKeys.SendWait("{DOWN}"); Playback.Wait(100); SendKeys.SendWait("{DOWN}"); Playback.Wait(100); SendKeys.SendWait("{ENTER}"); PopupDialogUIMap.WaitForDialog(); Playback.Wait(100); var confirmationDialog = UIBusinessDesignStudioWindow.GetChildren()[0]; var yesButton = confirmationDialog.GetChildren().FirstOrDefault(c => c.FriendlyName == "Yes"); Mouse.Click(yesButton, new Point(10, 10)); }
public WpfTree GetSourceNavigationTree() { var activeTab = TabManagerUIMap.GetActiveTab(); var deployUserControl = GetDeployUserControl(activeTab); return(VisualTreeWalker.GetChildByAutomationIdPath(deployUserControl, "SourceNavigationView", "Navigation") as WpfTree); }
/// <summary> /// DebugWindowExists /// </summary> /// public WpfRow GetRow(int row) { var debugWindow = GetDebugWindow(); debugWindow.WaitForControlEnabled(); var inputGrid = VisualTreeWalker.GetChildByAutomationIdPath(debugWindow, "TabItems", "UI_InputDataTab_AutoID", "DataListInputs"); return(inputGrid.GetChildren()[row] as WpfRow); }
public string GetStatus() { UITestControl statusRadioButton = VisualTreeWalker.GetChildByAutomationIdPath(_activeTab, _enabledRadioButtonAutoIds); if (statusRadioButton.IsSelected()) { return("Enabled"); } return("Disabled"); }
void DocumentsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Due to an issue with ElementFlow we need to synchronize the selected items manually var elementFlow = VisualTreeWalker.FindName <ElementFlow>("ef", DocumentsListBox); if (elementFlow != null) { elementFlow.SelectedIndex = DocumentsListBox.SelectedIndex; } }
private void AccessibilityDemoPage_Loaded(object sender, RoutedEventArgs e) { var analyzer = new AccessibilityAnalyzer(); var walker = new VisualTreeWalker(this, analyzer); walker.ScanVisualTree(); timer = new VisualTreeWalkerTimer(walker); timer.Start(); }
private WpfText GetTitleLabel(string autoId) { UITestControlCollection uiTestControlCollection = StudioWindow.GetChildren(); var tryGetDialog = uiTestControlCollection[0]; UITestControl childByAutomationIDPath = VisualTreeWalker.GetChildByAutomationIdPath(tryGetDialog, autoId); WpfText wpfText = childByAutomationIDPath as WpfText; if (wpfText != null) { return(wpfText); } throw new Exception("Could not find the " + autoId + " label."); }
public bool ServiceExists(string serverName, string folderName, string projectName) { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } return(theControl != null && theControl.Exists); }
private static void VerifyElementsVisitedCount(FrameworkElement root, int visitedNoteCount) { App.Content = root; var visitedItems = new List <FrameworkElement>(); var analyzer = new CountingElementAnalyzer(visitedItems); var walker = new VisualTreeWalker(root); walker.Analyzers.Add(analyzer); walker.ScanVisualTree(); Assert.AreEqual(visitedNoteCount, visitedItems.Count, "Should have visited every element exactly once."); }
public List <UITestControl> GetInputMappingRows() { UITestControl table = VisualTreeWalker.GetChildByAutomationIdPath(Activity, "LargeView", "Table"); if (table == null) { return(new List <UITestControl>()); } UITestControlCollection tableChildren = table.GetChildren(); List <UITestControl> rows = tableChildren.Where(c => c.ControlType == ControlType.Row).ToList(); return(rows); }
public List <string> GetActivityList() { List <string> activityNames = new List <string>(); WpfTable table = VisualTreeWalker.GetChildByAutomationIdPath(Activity, "SmallViewContent", "InitialFocusElement") as WpfTable; if (table != null) { var uiTestControlCollection = table.Rows; foreach (var control in uiTestControlCollection) { activityNames.Add(control.Name); } } return(activityNames); }
public OutputUIMap() { //_outputPane = VisualTreeWalker.GetControl("UI_DocManager_AutoID", "OutputPane", "DebugOutput"); //_outputEdit = VisualTreeWalker.GetControl("UI_DocManager_AutoID", "OutputPane", "Edit"); //_outputStatus = VisualTreeWalker.GetControl("UI_DocManager_AutoID", "OutputPane", "Edit", "Dev2StatusBarAutomationID", "StatusBar"); //_outputPane = VisualTreeWalker.GetControlFromRoot(true, 1, null, "UI_DocManager_AutoID", "Z96bb9badc4b148518ea4eff80920f8d9", "Zfb2fe4b8a0e84c8fb3fda8601e62a61e", "Zae7dc5529efd48379e593356fee56c4c", "OutputPane", "DebugOutput"); if (_outputPane == null) { _outputPane = VisualTreeWalker.GetControlFromRoot(true, 0, null, "UI_DocManager_AutoID", "Z96bb9badc4b148518ea4eff80920f8d9", "OutputPane", "DebugOutput"); } //_outputEdit = VisualTreeWalker.GetControlFromRoot(0, false, 1, "Uia.SplitPane", "Z96bb9badc4b148518ea4eff80920f8d9", "Zfb2fe4b8a0e84c8fb3fda8601e62a61e", "Zae7dc5529efd48379e593356fee56c4c", "OutputPane", "DebugOutput", "Edit"); if (_outputStatus == null) { _outputStatus = VisualTreeWalker.GetControlFromRoot(true, 0, _outputPane, "Dev2StatusBarAutomationID").GetChildren()[0]; } }
/// <summary> /// Drags the control automatic workflow designer. /// </summary> /// <param name="serverName">Name of the server.</param> /// <param name="serviceType">Type of the service.</param> /// <param name="folderName">Name of the folder.</param> /// <param name="projectName">Name of the project.</param> /// <param name="p">The application.</param> /// <param name="overrideDblClickBehavior">if set to <c>true</c> [override double click behavior].</param> public void DragControlToWorkflowDesigner(string serverName, string serviceType, string folderName, string projectName, Point p) { UITestControl theControl = null; if (folderName != "Unassigned" && folderName != "UNASSIGNED" && folderName != string.Empty) { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, folderName, projectName); } else { theControl = VisualTreeWalker.GetChildByAutomationIdPath(_explorerTree, serverName, projectName); } Mouse.StartDragging(theControl); Playback.Wait(20); Mouse.StopDragging(p); Playback.Wait(100); }
public void VerifyVisitingOrderIsBreadthFirstSearch() { App.Content = new BreadthFirsSearchTestTree(); var visitedItems = new List <FrameworkElement>(); var analyzer = new CountingElementAnalyzer(visitedItems); var walker = new VisualTreeWalker(App.Content); walker.Analyzers.Add(analyzer); walker.ScanVisualTree(); Assert.AreEqual(28, visitedItems.Count, "Should have visited every element exactly once."); for (int i = 0; i < visitedItems.Count; i++) { Assert.AreEqual(i.ToString(), visitedItems[i].Tag, "Should have visited items in specific orders"); } }
protected override void OnAttached() { base.OnAttached(); AssociatedObject.LayoutUpdated += AssociatedObject_EventHandler; AssociatedObject.Loaded += (s, e) => { var window = VisualTreeWalker.FindParent <Window>(AssociatedObject); window.LocationChanged += (ss, ee) => { if (!BlockReentrance) { ShouldCenter = false; } }; }; }
public UITestControl ClickRibbonMenuItem(string itemName, int waitAmt = 100) { var control = VisualTreeWalker.GetChildByAutomationIdPath(StudioWindow, itemName); if (control == null) { var message = string.Format("Resource with name : [{0}] was not found", itemName); throw new Exception(message); } control.WaitForControlEnabled(); var p = new Point(control.BoundingRectangle.X + 5, control.BoundingRectangle.Y + 5); Mouse.Click(p); Playback.Wait(waitAmt); return(control); }
public void ScansMultipleTimes() { var analyzer = new AnalyzeInvokeCountAnalyzer(); VisualTreeWalker walker = null; VisualTreeWalkerTimer timer = null; RunOnUIThread.Execute(() => { walker = new VisualTreeWalker(new Button(), analyzer); timer = new VisualTreeWalkerTimer(walker, 10); timer.Start(); }); RunOnUIThread.WaitMilliSeconds(500); Logger.LogMessage("Analyzer count: " + analyzer.AnalyzeCount); Assert.IsTrue(analyzer.AnalyzeCount >= 2); }