public static void Cleanup() { _testWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); _mainWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_WindowFocusTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
public void TypeKey_ControlAAfterTypingText_AllGetsSelected() { KeyboardEx.TypeText(_textBox, "Peter Sausage"); DynamicSleep.Wait(1000); KeyboardEx.TypeKey(_textBox, Key.A, ModifierKeys.Control).And.Wait(2000); Assert.AreEqual("Peter Sausage", _textBox.SelectedText); _textBox.Unsafe.SetValue(""); }
public void TypeText_PressShiftAndArrowLeftSevenTimes_SelectsPartOfTheText() { KeyboardEx.TypeText(_textBox, "Peter Sausage"); DynamicSleep.Wait(1000); Do.Action(() => KeyboardEx.TypeKey(Key.Left, ModifierKeys.Shift)).Repeat(6).And.Wait(500); Assert.AreEqual("Sausage", _textBox.SelectedText); _textBox.Unsafe.SetValue(""); }
public void Wait_WithMilliseconds_WaitsTheGivenTime() { var stopwatch = new Stopwatch(); stopwatch.Start(); DynamicSleep.Wait(1200); stopwatch.Stop(); Assert.IsTrue(stopwatch.Elapsed <TimeSpan.FromMilliseconds(1220) && stopwatch.Elapsed> TimeSpan.FromMilliseconds(1180), stopwatch.Elapsed.ToString()); }
public void Wait_WithAMediumParameter_Waits100Milliseconds() { var stopwatch = new Stopwatch(); stopwatch.Start(); DynamicSleep.Wait(Time.Medium); stopwatch.Stop(); Assert.IsTrue(stopwatch.Elapsed <TimeSpan.FromMilliseconds(120) && stopwatch.Elapsed> TimeSpan.FromMilliseconds(80), stopwatch.Elapsed.ToString()); }
public void Wait_WithoutParameter_UsesTheDefaultWaitTime() { var stopwatch = new Stopwatch(); stopwatch.Start(); DynamicSleep.Wait(); stopwatch.Stop(); Assert.IsTrue(stopwatch.Elapsed <TimeSpan.FromMilliseconds(1020) && stopwatch.Elapsed> TimeSpan.FromMilliseconds(800), stopwatch.Elapsed.ToString()); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
public void InvokePattern_ReadFromButton_CanInvoked() { var button = UI.GetChild(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(_mainWindow)); var pattern = Patterns.GetInvokePattern(button.AutomationElement); pattern.Invoke(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); }
public void Search_ForAMessageBox_FindsAndClosesIt() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var window = WindowFinder.Search <BasicWindow>(Use.AutomationId("CUI_TestApplication_MainWindow")); var button = UI.GetChild <BasicButton>(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(window)); button.Unsafe.Click(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); window.CloseButton.Unsafe.Click(); }
public void TypeKey_AltF4OnTheWindow_ClosesTheWindow() { KeyboardEx.TypeKey(_testWindow, Key.F4, ModifierKeys.Alt).And.Wait(2000); var testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert().And.Timeout(2000)); Assert.IsNull(testWindow); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
public void TypeText_MoreDifferentShiftSelections_SelectsTheTextAccordingly() { KeyboardEx.TypeText(_textBox, "Peter Sausage"); KeyboardEx.PressKey(Key.Enter); KeyboardEx.TypeText("Was Here"); DynamicSleep.Wait(1000); KeyboardEx.TypeKey(Key.Left, ModifierKeys.Shift); KeyboardEx.TypeKey(Key.Left, ModifierKeys.Shift); KeyboardEx.TypeKey(Key.Left, ModifierKeys.Shift); KeyboardEx.TypeKey(Key.Up, ModifierKeys.Shift); KeyboardEx.TypeKey(Key.Left, ModifierKeys.Shift).And.Wait(2000); Assert.AreEqual("Sausage\r\nWas Here", _textBox.SelectedText); _textBox.Unsafe.SetValue(""); }
public static void Cleanup() { var basicWindow = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow", CompareKind.StartsWith), And.NoAssert().And.Timeout(100)); if (basicWindow != null) { basicWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); } basicWindow = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow", CompareKind.StartsWith), And.NoAssert().And.Timeout(100)); if (basicWindow != null) { basicWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); } _mainWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); }