예제 #1
0
        public void ScrollTest()
        {
            UtilityMethods.IgnoreOnUIA2();
            using (var app = Application.Launch("notepad.exe"))
            {
                using (var automation = new UIA3Automation())
                {
                    var mainWindow      = app.GetMainWindow(automation);
                    var documentElement = mainWindow.FindFirstChild("15");
                    var sb = new StringBuilder();
                    for (var i = 0; i < 1000; i++)
                    {
                        sb.Append("aaa" + Environment.NewLine);
                    }
                    documentElement.Patterns.Value.Pattern.SetValue(sb.ToString());
                    Mouse.Position = documentElement.BoundingRectangle.Center();
                    Wait.UntilInputIsProcessed();

                    var initScroll = documentElement.Patterns.Scroll.Pattern.VerticalScrollPercent.Value;
                    Assert.That(initScroll, Is.EqualTo(0));
                    Mouse.Scroll(-100);
                    Wait.UntilInputIsProcessed();
                    var downScroll = documentElement.Patterns.Scroll.Pattern.VerticalScrollPercent.Value;
                    Assert.That(downScroll, Is.GreaterThan(initScroll));

                    Mouse.Scroll(100);
                    Wait.UntilInputIsProcessed();
                    var upScroll = documentElement.Patterns.Scroll.Pattern.VerticalScrollPercent.Value;
                    Assert.That(upScroll, Is.LessThan(downScroll));

                    UtilityMethods.CloseWindowWithDontSave(mainWindow);
                }
            }
        }
예제 #2
0
        public void KeyboardTest()
        {
            var app = Application.Launch("notepad.exe");

            using (var automation = new UIA3Automation())
            {
                var mainWindow = app.GetMainWindow(automation);

                Keyboard.Type("ééééééööööö aaa | ");

                Keyboard.Type(VirtualKeyShort.KEY_Z);
                Keyboard.Type(VirtualKeyShort.LEFT);
                Keyboard.Type(VirtualKeyShort.DELETE);
                Keyboard.Type(VirtualKeyShort.KEY_Y);
                Keyboard.Type(VirtualKeyShort.BACK);
                Keyboard.Type(VirtualKeyShort.KEY_X);

                Keyboard.Type(" | ");

                Keyboard.Type("ঋ ঌ এ ঐ ও ঔ ক খ গ ঘ ঙ চ ছ জ ঝ ঞ ট ঠ ড ঢ");

                Thread.Sleep(500);

                UtilityMethods.CloseWindowWithDontSave(mainWindow);
            }
            app.Dispose();
        }
예제 #3
0
        public void ClickTest()
        {
            var app = Application.Launch("mspaint");

            using (var automation = new UIA3Automation())
            {
                var mainWindow = app.GetMainWindow(automation);
                var mouseX     = mainWindow.Properties.BoundingRectangle.Value.Left + 50;
                var mouseY     = mainWindow.Properties.BoundingRectangle.Value.Top + 200;
                Mouse.Position = new Point(mouseX, mouseY);
                Mouse.Down(MouseButton.Left);
                Mouse.MoveBy(100, 10);
                Mouse.MoveBy(10, 50);
                Mouse.Up(MouseButton.Left);
                Thread.Sleep(500);
                UtilityMethods.CloseWindowWithDontSave(mainWindow);
            }
            app.Dispose();
        }