示例#1
0
        public void ListOfControlsTableTest()
        {
            var fixture = new UiAutomationFixture();

            fixture.StartApplication("notepad");
            var processId      = fixture.ApplicationProcessId;
            var listOfControls = new ListOfControls(processId, "ProcessId:" + processId);
            var result         = listOfControls.DoTable();
            var headerRow      = result[0] as Collection <string>;

            Assert.IsNotNull(headerRow);
            Assert.AreEqual("report:Name", headerRow[1]);
            var controls = result.Skip(1).ToList();

            Assert.IsTrue(controls.Any());
            foreach (Collection <string> row in controls)
            {
                foreach (var cell in row)
                {
                    Console.Write(cell + "; ");
                }
                Console.WriteLine();
            }

            var emptyList   = new ListOfControls(processId, "id:q");
            var emptyResult = emptyList.Query();

            Assert.IsNull(emptyResult);
            fixture.ForcedCloseApplication();
        }
示例#2
0
        public void FixtureIsUwpTest()
        {
            var fixture = new UiAutomationFixture();

            fixture.StartApplication("notepad");
            Assert.IsNotNull(fixture.ApplicationProcessId);
            var process = Process.GetProcessById(fixture.ApplicationProcessId.Value);

            Assert.IsFalse(AppLauncher.IsUwpApp(process.Handle), "Notepad is not UWP");
            Assert.IsTrue(fixture.CloseApplication(), "Close notepad");
            fixture.StartApplicationWithArguments(@"windows.immersivecontrolpanel_cw5n1h2txyewy", null);
            Assert.IsNotNull(fixture.ApplicationProcessId);
            var pid = fixture.ApplicationProcessId.Value;

            process = Process.GetProcessById(pid);
            Assert.IsTrue(AppLauncher.IsUwpApp(process.Handle), "App is UWP");
            Assert.AreEqual(IntPtr.Zero, process.MainWindowHandle, "Main window handle for Uwp window is 0");
            Assert.IsTrue(fixture.SwitchToParentWindow(), "Switch to parent");
            Assert.AreNotEqual(pid, fixture.ApplicationProcessId, @"Pids are not equal");
            Assert.IsTrue(AppLauncher.IsUwpApp(process.Handle), "Parent is UWP");
            Assert.IsNotNull(fixture.ApplicationProcessId);
            process = Process.GetProcessById(fixture.ApplicationProcessId.Value);
            Assert.AreNotEqual(IntPtr.Zero, process.MainWindowHandle, "Main window handle for Uwp parent window is not 0");
            Assert.IsTrue(fixture.SwitchToProcess("ProcessId:" + pid), "Switch to child");
            Assert.IsTrue(fixture.CloseApplication(), "Close UWP app");
        }
 public static void Win10SetupCalc(TestContext testContext)
 {
     _fixture = new UiAutomationFixture();
     UiAutomationFixture.TimeoutSeconds = 5;
     Assert.IsFalse(_fixture.SwitchToProcess("name:Calculator"), "Check there is no calculator running already");
     _fixture.NoAutomaticSwitchToStartedApplication();
     _fixture.StartApplication("calc.exe");
     Assert.IsTrue(UiAutomationFixture.WaitForProcess("name:Calculator"), "Wait for process Calculator");
     Assert.IsTrue(_fixture.SwitchToProcess("name:Calculator"), "Switch to calc app");
 }
        public void PatternTest1()
        {
            var fixture = new UiAutomationFixture();

            try
            {
                UiAutomationFixture.TimeoutSeconds = 1;
                UiAutomationFixture.SearchBy("Name");
                Assert.IsTrue(fixture.StartApplication("notepad.exe"), "Notepad started");
                var control = fixture.GetControl("classname:edit");
                var pattern = new LegacyIAccessiblePattern(control.AutomationElement);
                Assert.AreEqual(SetResult.Success, pattern.TrySet("hello"));
                Assert.IsTrue(pattern.TryGet(out var content));
                Assert.AreEqual("hello", content);
            }
            finally
            {
                fixture.ForcedCloseApplication();
            }
        }
 public void Init()
 {
     _fixture = new UiAutomationFixture();
     Assert.IsTrue(_fixture.StartApplication("notepad.exe"), "notepad started");
     _fixture.WaitForControl(@"controltype:edit");
 }
示例#6
0
 public void FixtureNonExistingCmdTest()
 {
     Assert.IsFalse(_fixture.StartApplication("nonexisting.cmd"), @"nonexisting cmd file");
     Assert.IsNull(_fixture.ApplicationProcessId);
 }