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(); }
public void WpfDemoCheckExpandCollapse() { Assert.IsTrue(_fixture.SelectItem("Caption:Usual Controls"), "Select 'Usual Controls' tab"); Assert.IsTrue(UiAutomationFixture.SearchBy("Caption"), "Default search is by Caption"); Assert.IsTrue(_fixture.SelectItem("Tree View"), "Select 'Tree View' tab"); Assert.IsFalse(_fixture.ControlExists("Step 2"), "Step 2 tree item does not exist yet"); Assert.IsTrue(_fixture.ExpandControl("ID:TreeView1"), "Expanding TreeView1 succeeds"); Assert.IsTrue(_fixture.ExpandControl("Processes"), "Expand Processes"); Assert.IsTrue(_fixture.SetFocusToControl("Main Process 1")); Assert.IsTrue(_fixture.ExpandControl("Main Process 1"), "Expand Main Process 1"); Assert.IsTrue(_fixture.SetFocusToControl("Sub Process 1")); Assert.IsTrue(_fixture.ExpandControl("Sub Process 1"), "Expand Sub Process 1"); Assert.IsTrue(_fixture.SetFocusToControl("Step 2")); Assert.IsTrue(_fixture.ControlExists("Step 2"), "Step 2 tree item now exists"); Assert.IsTrue(_fixture.ControlIsVisible("Step 2"), "Step 2 tree item is visible"); Assert.IsTrue(_fixture.ExpandControl("Products"), "Expanding already expanded control is OK"); Assert.IsTrue(_fixture.ControlIsVisible("Core Product 1"), "Core Product 1 tree item is still visible"); Assert.IsTrue(_fixture.CollapseControl("Processes"), "Collapsing Processes tree item"); Assert.IsTrue(_fixture.ControlExists("Step 2"), "Step 2 tree item still exists"); Assert.IsFalse(_fixture.ControlIsVisible("Step 2"), "Ste p2 tree item is now invisible"); Assert.IsTrue(_fixture.CollapseControl("ID:TreeView1"), "Collapsing TreeView1"); Assert.IsFalse(_fixture.ControlIsVisible("Core Product 1"), "Core Product 1 tree item is now invisible"); }