public void GenerateCommands() { if (Disposed) { throw new ObjectDisposedException("Attempted to access InputHandler after object is disposed!"); } MouseCommands.Clear(); KeyCommands.Clear(); MousePosition = MouseHistory[0].Position; for (Byte a = 0; a < MouseListeners.Count; a++) { switch (MouseListeners[a]) { case MouseKeys.LeftButton: HandleLeftMouseButton(); break; case MouseKeys.MiddleButton: HandleMiddleMouseButton(); break; case MouseKeys.RightButton: HandleRightMouseButton(); break; } } for (Int16 b = 0; b < KeyboardListeners.Count; b++) { HandleKeyboardButton(KeyboardListeners[b]); } }
public void SqlBulkInsertTest_OpenQuickVariableInputAndCloseItImmediately_ReturnsToSmallView() { // Create the workflow RibbonUIMap.CreateNewWorkflow(); var theTab = TabManagerUIMap.GetActiveTab(); // Get some variables var startPoint = WorkflowDesignerUIMap.GetStartNodeBottomAutoConnectorPoint(theTab); var point = new Point(startPoint.X, startPoint.Y + 200); // Drag the tool onto the workflow ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.SqlBulkInsert, point, "Sql Bulk"); //Open the quick variable input view var toggleButton = GetControlByFriendlyName("Open Quick Variable Input"); MouseCommands.ClickControlAtPoint(toggleButton, new Point(5, 5)); WaitForControlLoad(); var quickVarInputContent = GetControlByFriendlyName("QuickVariableInputContent"); Assert.IsNotNull(quickVarInputContent); //Close the quick variable input view toggleButton = GetControlByFriendlyName("Close Quick Variable Input"); MouseCommands.ClickControlAtPoint(toggleButton, new Point(5, 5)); WaitForControlLoad(); var smallDataGrid = GetControlById("SmallDataGrid", theTab); Assert.IsNotNull(smallDataGrid); }
public void QuickVariableInputFromListTest() { Clipboard.Clear(); // Create the workflow RibbonUIMap.CreateNewWorkflow(); // Get some variables UITestControl theTab = TabManagerUIMap.GetActiveTab(); Point startPoint = WorkflowDesignerUIMap.GetStartNodeBottomAutoConnectorPoint(theTab); Point point = new Point(startPoint.X - 100, startPoint.Y + 100); // Drag the tool onto the workflow ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.Assign, point); //Get Mappings button UITestControl button = WorkflowDesignerUIMap.Adorner_GetButton(theTab, "Assign", "Open Quick Variable Input"); // Click it MouseCommands.MoveAndClick(new Point(button.BoundingRectangle.X + 5, button.BoundingRectangle.Y + 5)); // Enter some invalid data WorkflowDesignerUIMap.AssignControl_QuickVariableInputControl_EnterData(theTab, "Assign", ",", "some(<).", "_suf", "varOne,varTwo,varThree"); // Click done WorkflowDesignerUIMap.AssignControl_QuickVariableInputControl_ClickAdd(theTab, "Assign"); var errorControl = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Prefix contains invalid characters"); Assert.IsNotNull(errorControl, "No error displayed for incorrect QVI input"); #region Scroll Right var scrollBarH = WorkflowDesignerUIMap.ScrollViewer_GetHorizontalScrollBar(theTab); WorkflowDesignerUIMap.ScrollViewer_GetHorizontalScrollBar(theTab); // Look far right Mouse.StartDragging(scrollBarH); Mouse.StopDragging(WorkflowDesignerUIMap.ScrollViewer_GetScrollRight(theTab)); #endregion // Assert clicking an error focuses the correct text-box MouseCommands.ClickControl(errorControl.GetChildren()[0]); // enter some correct data KeyboardCommands.SendKey("^a^xpre_", 100); WorkflowDesignerUIMap.AssignControl_QuickVariableInputControl_ClickAdd(theTab, "Assign"); // Check the data string varName = WorkflowDesignerUIMap.AssignControl_GetVariableName(theTab, "Assign", 0); StringAssert.Contains(varName, "[[pre_varOne_suf]]"); }
/// <summary> /// This method is used to calculate the First level of probability of a given command /// </summary> /// <param name="command"></param> public Dictionary <CommandType, object> CalculateProbabilityOfCommand(string command) { try { var probableCommands = new List <CommandType>(); new NaiveCommandCategorization(_categoryCollection).CalculateProbabilityOfSegments( command.Split(' ').ToList(), true, out _probabilityScoreIndices); if (_probabilityScoreIndices == null) { return(null); } var highestProbabilityCategories = new NaiveCommandCategorization().GetHighestProbabilityScoreIndeces(_probabilityScoreIndices); if (highestProbabilityCategories.Count == 1) { var firstLevelHighestProbabilityCategory = highestProbabilityCategories.First(); if (firstLevelHighestProbabilityCategory.ReferenceId == Conversions.ConvertEnumToInt(FirstLevelCategory.FunctionalCommand)) { probableCommands = new SecondLevelCategorization().CalculateSecondLevelProbabilityOfCommand(command); } else if (firstLevelHighestProbabilityCategory.ReferenceId == Conversions.ConvertEnumToInt(FirstLevelCategory.KeyboardCommand)) { probableCommands = new KeyboardCommands(command).GetCommand(); } else if (firstLevelHighestProbabilityCategory.ReferenceId == Conversions.ConvertEnumToInt(FirstLevelCategory.MouseCommand)) { probableCommands = new MouseCommands(command).GetCommand(); } } else { throw new Exception("Command Identification Failed From the First Level. There are " + highestProbabilityCategories.Count + " probable categories which are " + DataManager.GetHighestProbableCommandTypesForException <FirstLevelCategory>(highestProbabilityCategories)); } var returnDict = GetCommandDetails(probableCommands, command); if (returnDict.Count == 1) { var identifiedCommandType = returnDict.First().Key; if (LearningManager.UnIdentifiedWords.Count > 0) { LearningManager.AddUnidentifiedWordsToCommandText(identifiedCommandType); } DataManager.AddToCommandCounter(identifiedCommandType); } return(returnDict); } catch (Exception ex) { Log.ErrorLog(ex); throw; } }
public void Dispose() { if (Disposed) { return; } MouseHistory.Dispose(); KeyboardHistory.Dispose(); MouseListeners.Clear(); KeyboardListeners.Clear(); MouseCommands.Clear(); KeyCommands.Clear(); Disposed = true; }
// 05/11 - Failure is Intermittent - Problems finding LargeView button ;) public void SqlBulkInsertTest_SelectDatabaseAndTableName_GridHasColumnnames() { // Create the workflow RibbonUIMap.CreateNewWorkflow(); var theTab = TabManagerUIMap.GetActiveTab(); var startPoint = WorkflowDesignerUIMap.GetStartNodeBottomAutoConnectorPoint(theTab); var point = new Point(startPoint.X, startPoint.Y + 200); // Drag the tool onto the workflow ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.SqlBulkInsert, point, "Sql Bulk"); //Select a database var dbDropDown = GetControlById("UI__Database_AutoID", theTab) as WpfComboBox; MouseCommands.ClickControlAtPoint(dbDropDown, new Point(10, 10)); WaitForControlLoad(15000); if (dbDropDown != null) { var listOfDbNames = dbDropDown.Items.Select(i => i as WpfListItem).ToList(); var databaseName = listOfDbNames.SingleOrDefault(i => i.DisplayText.Contains(TestingDb)); MouseCommands.ClickControlAtPoint(databaseName, new Point(5, 5)); } //Select a table var tableDropDown = GetControlById("UI__TableName_AutoID", theTab) as WpfComboBox; MouseCommands.ClickControlAtPoint(tableDropDown, new Point(10, 10)); WaitForControlLoad(15000); if (tableDropDown != null) { var listOfTableNames = tableDropDown.Items.Select(i => i as WpfListItem).ToList(); WaitForControlLoad(2500); MouseCommands.ClickControlAtPoint(listOfTableNames[TableIndex], new Point(5, 5)); } WaitForControlLoad(3000); //Assert that grid is not empty var smallDataGrid = GetControlById("SmallDataGrid", theTab); Assert.IsTrue(smallDataGrid.GetChildren().Count > 0); }
public void DragAWorkflowIntoAndOutOfAForEach_Expected_NoErrors() { // Create the workflow RibbonUIMap.CreateNewWorkflow(); // Get some variables UITestControl theTab = TabManagerUIMap.GetActiveTab(); UITestControl theStartButton = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Start"); Point workflowPoint1 = new Point(theStartButton.BoundingRectangle.X, theStartButton.BoundingRectangle.Y + 200); Point requiredPoint = WorkflowDesignerUIMap.GetPointUnderStartNode(theTab); requiredPoint.Offset(20, 50); // Drag a ForEach onto the Workflow ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.ForEach, workflowPoint1, "For Each"); // Get a sample workflow, and drag it onto the "Drop Activity Here" part of the ForEach box ExplorerUIMap.EnterExplorerSearchText("CalculateTaxReturns"); var targetPoint = new Point(workflowPoint1.X + 25, workflowPoint1.Y + 25); ExplorerUIMap.DragControlToWorkflowDesigner("localhost", "WORKFLOWS", "MO", "CalculateTaxReturns", targetPoint); // Now - Onto Part 2! // 5792.2 // Get the location of the ForEach box UITestControl forEachControl = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "ForEach"); MouseCommands.MoveAndClick(new Point(forEachControl.BoundingRectangle.X + 175, forEachControl.BoundingRectangle.Y + 75)); // And drag it down Mouse.StartDragging(); Mouse.StopDragging(new Point(workflowPoint1.X - 200, workflowPoint1.Y + 100)); // Now get its position UITestControl calcTaxReturnsControl = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "CalculateTaxReturns"); // Its not on the design surface, must be in foreach Assert.IsNotNull(calcTaxReturnsControl, "Could not drop it ;("); }
private void HandleMiddleMouseButton() { if (MouseHistory[0].MiddleButton == ButtonState.Pressed) { if (MouseHistory[1].MiddleButton == ButtonState.Pressed) { MouseCommands.Add(new MouseCommand(MouseKeys.MiddleButton, InputState.Held, MouseHistory[0].Position)); } else { MouseCommands.Add(new MouseCommand(MouseKeys.MiddleButton, InputState.Pressed, MouseHistory[0].Position)); } } else if (MouseHistory[1].MiddleButton == ButtonState.Pressed) { MouseCommands.Add(new MouseCommand(MouseKeys.MiddleButton, InputState.Released, MouseHistory[0].Position)); } }
private void HandleLeftMouseButton() { if (MouseHistory[0].LeftButton == ButtonState.Pressed) { if (MouseHistory[1].LeftButton == ButtonState.Pressed) //Adds a one frame latency. { MouseCommands.Add(new MouseCommand(MouseKeys.LeftButton, InputState.Held, MouseHistory[0].Position)); } else { MouseCommands.Add(new MouseCommand(MouseKeys.LeftButton, InputState.Pressed, MouseHistory[0].Position)); } } else if (MouseHistory[1].LeftButton == ButtonState.Pressed) { MouseCommands.Add(new MouseCommand(MouseKeys.LeftButton, InputState.Released, MouseHistory[0].Position)); } }
public void UnsavedStar_UITest_WhenWorkflowIsChanged_ExpectStarIsShowing() { //------------Setup for test-------------------------- RibbonUIMap.CreateNewWorkflow(); // Get some data var tabName = TabManagerUIMap.GetActiveTabName(); UITestControl theTab = TabManagerUIMap.FindTabByName(tabName); UITestControl theStartButton = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Start"); Point workflowPoint1 = new Point(theStartButton.BoundingRectangle.X, theStartButton.BoundingRectangle.Y + 200); // Drag a Multi Assign on ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.Assign, workflowPoint1); // Click away MouseCommands.ClickPoint(new Point(workflowPoint1.X + 50, workflowPoint1.Y + 50), 500); //------------Execute Test--------------------------- var theUnsavedTab = TabManagerUIMap.GetActiveTab(); //------------Assert Results------------------------- Assert.IsNotNull(theUnsavedTab, "Editted workflow does not have the unsaved * after its name on the tab"); }
public void DebugOutput_WhenStopped_WaitsForRenderToCompleteBeforeStoppedMessage() { try { //------------Setup for test-------------------------- //Open the correct workflow ExplorerUIMap.DoubleClickWorkflow("CodedUI_DebugOutputStop", "TESTS"); string status = OutputUIMap.GetStatusBarStatus(); Assert.AreEqual("Ready", status); UITestControl debugButton = RibbonUIMap.ClickDebug(); Point debugButtonPoint = new Point(debugButton.BoundingRectangle.X + 5, debugButton.BoundingRectangle.Y + 5); DebugUIMap.ClickExecute(1500); MouseCommands.ClickPoint(debugButtonPoint, 500); //------------Assert Results------------------------- status = OutputUIMap.GetStatusBarStatus(); StringAssert.Contains(status, "Ready"); } catch (Exception e) { Assert.Fail("It appears there is a debug issue. [ " + e.Message + " ]"); } }
public void SqlBulkInsertTest_OpenLargeViewAndEnterAnInvalidBatchAndTimeoutSizeAndClickDone_CorrectingErrorsAndClickDoneWillReturnToSmallView() { // Open the Explorer ExplorerUIMap.EnterExplorerSearchText("Sql Bulk Insert Large View"); // Open the Workflow ExplorerUIMap.DoubleClickOpenProject("localhost", "UI TEST", "Sql Bulk Insert Large View"); var theTab = TabManagerUIMap.GetActiveTab(); //Select a database var dbDropDown = GetControlById("UI__Database_AutoID", theTab) as WpfComboBox; Mouse.Click(dbDropDown, new Point(10, 10)); WaitForControlLoad(); if (dbDropDown != null) { var listOfDbNames = dbDropDown.Items.Select(i => i as WpfListItem).ToList(); var databaseName = listOfDbNames.SingleOrDefault(i => i.DisplayText.Contains(TestingDb)); Mouse.Click(databaseName, new Point(5, 5)); } WaitForControlLoad(5000); //Select a table var tableDropDown = GetControlById("UI__TableName_AutoID", theTab) as WpfComboBox; Mouse.Click(tableDropDown, new Point(10, 10)); WaitForControlLoad(10000); if (tableDropDown != null) { var listOfTableNames = tableDropDown.Items.Select(i => i as WpfListItem).ToList(); WaitForControlLoad(); Mouse.Click(listOfTableNames[TableIndex], new Point(5, 5)); } WaitForControlLoad(5000); UITestControl controlOnWorkflow = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "DsfSqlBulkInsertActivity"); //Open the large view using context menu WorkflowDesignerUIMap.OpenCloseLargeViewUsingContextMenu(theTab, "DsfSqlBulkInsertActivity"); WaitForControlLoad(5000); //Enter a few mappings // THIS IS FAULTY LOGIC!!!! var getFirstTextbox = WorkflowDesignerUIMap.GetSqlBulkInsertLargeViewFirstInputTextbox(controlOnWorkflow); if (getFirstTextbox == null) { throw new Exception("Failed to Locate Text Box"); } Mouse.Click(getFirstTextbox); KeyboardCommands.SendKey("^a^xrecord().id"); KeyboardCommands.SendTab(); KeyboardCommands.SendKey("^a^xrecord().name"); KeyboardCommands.SendTab(); KeyboardCommands.SendKey("^a^xrecord().mail"); KeyboardCommands.SendTab(); WaitForControlLoad(); var batchSize = GetControlById("UI__BatchSize_AutoID", theTab); MouseCommands.ClickControlAtPoint(batchSize, new Point(5, 5)); KeyboardCommands.SendKey("^a^x-2"); var timeout = GetControlById("UI__Timeout_AutoID", theTab); MouseCommands.ClickControlAtPoint(timeout, new Point(5, 5)); KeyboardCommands.SendKey("^a^x-2"); var result = GetControlById("UI__Result_AutoID", theTab); MouseCommands.ClickControlAtPoint(result, new Point(5, 5)); KeyboardCommands.SendKey("^a^x-2"); var done = GetControlById("DoneButton", theTab); MouseCommands.ClickControlAtPoint(done, new Point(5, 5)); WaitForControlLoad(); var batchErrorMessage = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Batch size must be a number"); MouseCommands.MoveAndClick(new Point(batchErrorMessage.GetChildren()[0].BoundingRectangle.X + 5, batchErrorMessage.GetChildren()[0].BoundingRectangle.Y + 5)); KeyboardCommands.SendKey("^a^x200"); var timeoutErrorMessage = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Timeout must be a number"); MouseCommands.MoveAndClick(new Point(timeoutErrorMessage.GetChildren()[0].BoundingRectangle.X + 5, timeoutErrorMessage.GetChildren()[0].BoundingRectangle.Y + 5)); KeyboardCommands.SendKey("^a^x200"); MouseCommands.ClickControlAtPoint(done, new Point(5, 5)); batchErrorMessage = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Batch size must be a number"); timeoutErrorMessage = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Timeout must be a number"); Assert.IsNull(batchErrorMessage); Assert.IsNull(timeoutErrorMessage); }