Exemple #1
0
        public void FixtureRunWord()
        {
            // Word doesn't always start a new process, but will re-use an existing process if that was already running.
            // That's why we don't use the automatic switch to the process, but switch by its process name separately
            var fixture = new UiAutomationFixture();

            UiAutomationFixture.SearchBy("Name");
            fixture.NoAutomaticSwitchToStartedApplication();
            UiAutomationFixture.TimeoutSeconds = 10;
            Assert.IsTrue(fixture.StartApplicationWithArguments(WordPath, "/w /q"), "Started Word");
            UiAutomationFixture.WaitSeconds(3);
            // todo: this fails when Word is already active when the test runs. Make more resilient
            Assert.IsTrue(fixture.SwitchToProcess(@"name:winword"), "Switched to Word");

            fixture.PressKey(@"The Quick Brown Fox Jumps Over the Lazy Dog+{HOME}");
            Assert.IsTrue(fixture.ClickControl("ControlType:Button && Name:Bold"), "Click Bold");
            Assert.IsTrue(fixture.ControlExists("Name:Heading 1"), "Heading 1 found");
            Assert.IsTrue(fixture.ClickControl("Heading 1"), "Click Heading 1");
            Assert.IsTrue(fixture.ClickControl("ControlType:Button && Name:Underline"), "Click Underline");
            Assert.IsFalse(fixture.CloseApplication(), "Close application doesn't work due to dialog");

            // This is a tricky one, as it is a control on a modal dialog.
            // It works because click has a fallback to simulate a mouseclick in the center of the control's bounding rectangle

            Assert.IsTrue(fixture.ClickControl("Name:Don't Save"), "click Don't Save");
            // Normally exiting Word can take a very long time. 10 seconds is typically not enough
            UiAutomationFixture.TimeoutSeconds = 30;
            Assert.IsTrue(UiAutomationFixture.WaitUntilProcessEnds(@"winword"), "WinWord process ends");
            UiAutomationFixture.TimeoutSeconds = 3;
            fixture.SetAutomaticSwitchToStartedApplication();
        }
Exemple #2
0
        public static void PrepareTestSuite(TestContext testContext)
        {
            UiAutomationFixture.TimeoutSeconds = 10;
            _fixture = new UiAutomationFixture();
            _fixture.SetAutomaticSwitchToStartedApplication();
            Assert.IsTrue(_fixture.StartApplicationWithWorkingFolder(WpfDemoAppPath, TempFolder), "WpfDemoApp started with working folder");
            _fixture.WaitForControl("id:workingFolder");
            var actualWorkFolder = _fixture.ValueOfControl("id:WorkingFolder");

            Assert.AreEqual(TempFolder, actualWorkFolder, "Working folder is OK");
            Assert.IsTrue(_fixture.CloseApplication(), "WPF Demo App stopped");
            Assert.IsTrue(_fixture.StartApplicationWithWorkingFolder(WpfDemoAppPath, ""), "WpfDemoApp started with empty working folder");
            Assert.AreNotEqual(TempFolder, _fixture.ValueOfControl("id:WorkingFolder"), "Working folder is OK 2");
        }
Exemple #3
0
        public void FixtureStartAndSwitchTestOnWord2016()
        {
            UiAutomationFixture.TimeoutSeconds = 3;
            Assert.IsFalse(_fixture.SwitchToProcess(@"name:winword"), "Word not running already");
            _fixture.NoAutomaticSwitchToStartedApplication();
            UiAutomationFixture.TimeoutSeconds = 10;
            // command line switch /w opens Word with a blank page.
            Assert.IsTrue(_fixture.StartApplicationWithArguments(WordPath, "/w /q"), @"first start of Winword succeeds (no autoswitch)");
            var processId = _fixture.ApplicationProcessId;

            Assert.IsTrue(UiAutomationFixture.WaitForProcess("ProcessId:" + processId), "Wait for Word process");
            Assert.IsTrue(_fixture.SwitchToProcess("ProcessId:" + processId), "Now Word is running");
            _fixture.SetAutomaticSwitchToStartedApplication();
            Assert.IsTrue(_fixture.StartApplicationWithArguments(WordPath, "/w /q"), @"second start of Winword succeeds too (autoswitch)");
            Assert.AreNotEqual(processId, _fixture.ApplicationProcessId, "Process IDs are not equal");
            Assert.IsTrue(_fixture.ForcedCloseApplication(), "Forced close of 2nd instance succeeds");
            Assert.IsTrue(_fixture.SwitchToProcess("ProcessId:" + processId), "Can switch to first Word instance");
            Assert.IsTrue(_fixture.ForcedCloseApplication(), "Forced close 1st instance succeeds");
            Assert.IsTrue(UiAutomationFixture.WaitUntilProcessEnds(@"name:winword"), "WinWord process ends");
        }