Esempio n. 1
0
        public static void DrawCircle(WindowsDriver <WindowsElement> session)
        {
            // Draw a circle with radius 300 and 40 (x, y) points
            const int radius = 300;
            const int points = 40;

            // Select the Brushes toolbox to have the Brushes Pane sidebar displayed and ensure that Marker is selected
            session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click();
            session.FindElementByAccessibilityId("SidebarWrapper").FindElementByAccessibilityId("Marker3d").Click();

            // Locate the drawing surface
            WindowsElement inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper");

            // Draw the circle with a single touch actions
            OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
            ActionSequence touchSequence = new ActionSequence(touchContact, 0);

            touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, 0, -radius, TimeSpan.Zero));
            touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            for (double angle = 0; angle <= 2 * Math.PI; angle += 2 * Math.PI / points)
            {
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero));
            }
            touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                touchSequence
            });

            // Verify that the drawing operations took place
            WindowsElement undoButton = session.FindElementByAccessibilityId("UndoIcon");
        }
Esempio n. 2
0
        public void Touch_Flick()
        {
            // Navigate to add alarm page
            session.FindElementByAccessibilityId("AddAlarmButton").Click();
            session.FindElementByAccessibilityId("AlarmTimePicker").Click();
            Thread.Sleep(TimeSpan.FromSeconds(1));

            WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector");
            WindowsElement minute00       = session.FindElementByName("00");

            Assert.IsNotNull(minuteSelector);
            Assert.IsNotNull(minute00);
            Assert.IsTrue(minute00.Displayed);

            // Perform touch flick down action to scroll the minute hiding 00 minutes that was shown
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(minuteSelector, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerMove(minuteSelector, 0, 500, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.IsFalse(minute00.Displayed);
        }
Esempio n. 3
0
        public void Touch_DragAndDrop()
        {
            WindowsElement appNameTitle = FindAppTitleBar();
            const int      offset       = 100;

            // Save application window original position
            Point originalPosition = session.Manage().Window.Position;

            Assert.IsNotNull(originalPosition);

            // Send touch down, move, and up actions combination to perform a drag and drop
            // action on the app title bar. These actions reposition the application window.
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(appNameTitle, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Pointer, offset, offset, TimeSpan.FromSeconds(1)));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(1));

            // Verify that application window is now re-positioned from the original location
            Assert.AreNotEqual(originalPosition, session.Manage().Window.Position);
            Assert.IsTrue(originalPosition.Y < session.Manage().Window.Position.Y);

            // Restore application window original position
            session.Manage().Window.Position = originalPosition;
            Assert.AreEqual(originalPosition, session.Manage().Window.Position);
        }
Esempio n. 4
0
        public void ZoomingOutMultiTouchWithInterpolation()
        {
            // Set pointer move Duration to 300 ms to implicitly generate 6 interpolation moves that are performed every 50 ms
            TimeSpan moveDuration = TimeSpan.FromMilliseconds(300);

            // Drag a touch contact diagonally in SW direction approaching the other contact point
            PointerInputDevice touch1         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touch1Sequence = new ActionSequence(touch1, 0);

            touch1Sequence.AddAction(touch1.CreatePointerMove(zoomInteractor, 50, -50, TimeSpan.Zero));
            touch1Sequence.AddAction(touch1.CreatePointerDown(PointerButton.TouchContact));
            touch1Sequence.AddAction(touch1.CreatePointerMove(zoomInteractor, 20, -20, moveDuration));
            touch1Sequence.AddAction(touch1.CreatePointerUp(PointerButton.TouchContact));

            // Drag a touch contact diagonally in NE direction approaching the other contact point
            PointerInputDevice touch2         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touch2Sequence = new ActionSequence(touch2, 0);

            touch2Sequence.AddAction(touch2.CreatePointerMove(zoomInteractor, -50, 50, TimeSpan.Zero));
            touch2Sequence.AddAction(touch2.CreatePointerDown(PointerButton.TouchContact));
            touch2Sequence.AddAction(touch2.CreatePointerMove(zoomInteractor, -20, 20, moveDuration));
            touch2Sequence.AddAction(touch2.CreatePointerUp(PointerButton.TouchContact));

            // Perform the 2 fingers zoom out (pinch) multi-touch sequences defined above
            session.PerformActions(new List <ActionSequence> {
                touch1Sequence, touch2Sequence
            });

            // Ensure that the zoom level now is less than 100%
            Assert.IsTrue(int.Parse(zoomScaleTextBox.Text) < 100);
        }
Esempio n. 5
0
        public void Touch_LongClick()
        {
            // Create a new test alarm
            string alarmName = "LongTapTest";

            DeletePreviouslyCreatedAlarmEntry(alarmName);
            AddAlarmEntry(alarmName);
            Thread.Sleep(TimeSpan.FromSeconds(3));

            var alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]");

            Assert.IsNotNull(alarmEntries);
            Assert.AreEqual(1, alarmEntries.Count);

            // Open a the context menu on the alarm entry using long tap (press and hold) action and click delete
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(alarmEntries[0], 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerMove(alarmEntries[0], 0, 0, TimeSpan.FromSeconds(3)));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            session.FindElementByName("Delete").Click();
            Thread.Sleep(TimeSpan.FromSeconds(1));

            alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]");
            Assert.IsNotNull(alarmEntries);
            Assert.AreEqual(0, alarmEntries.Count);
        }
Esempio n. 6
0
        public void DrawConcentricSquaresWithVaryingDuration()
        {
            const int             concentricSquareCount = 8; // Paint application only supports up to 10 touch inputs
            List <ActionSequence> actionSequencesList   = new List <ActionSequence>();

            // Draw N concentric rectangles with varying speed defined by the duration specified in durationMs
            for (int i = 0, radius = defaultRadius, durationMs = 1000; i < concentricSquareCount && radius > 0; i++, radius -= radiusOffset)
            {
                OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
                ActionSequence touchSequence = new ActionSequence(touchContact, 0);
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, -radius, TimeSpan.Zero));
                touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, radius, -radius, TimeSpan.FromMilliseconds(durationMs)));
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, radius, radius, TimeSpan.FromMilliseconds(durationMs)));
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, radius, TimeSpan.FromMilliseconds(durationMs)));
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, -radius, TimeSpan.FromMilliseconds(durationMs)));
                touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
                actionSequencesList.Add(touchSequence);
                durationMs += 300;
            }

            ourSession.PerformActions(actionSequencesList);

            // Verify that the drawing operations took place
            Assert.IsTrue(undoButton.Displayed);
            Assert.IsTrue(undoButton.Enabled);
        }
Esempio n. 7
0
        public void DrawBasicSquareWithExtraAttributes()
        {
            Point canvasCoordinate = inkCanvas.Coordinates.LocationInViewport;
            Size  squareSize       = new Size(inkCanvas.Size.Width * 3 / 5, inkCanvas.Size.Height * 3 / 5);
            Point A = new Point(canvasCoordinate.X + inkCanvas.Size.Width / 5, canvasCoordinate.Y + inkCanvas.Size.Height / 5);

            // A        B
            //  ┌──────┐   Draw a basic ABCD square using Pen through the Actions API
            //  │      │   in pointer origin mode:
            //  │      │   - X is relative to the previous X position in this session
            //  └──────┘   - Y is relative to the previous Y position in this session
            // D        C
            PointerInputDevice penDevice          = new PointerInputDevice(PointerKind.Pen);
            ActionSequence     sequence           = new ActionSequence(penDevice, 0);
            PenInfo            penExtraAttributes = new PenInfo {
                TiltX = 45, TiltY = 45, Twist = 45
            };

            // Draw line AB from point A to B with attributes defined in penExtraAttributes
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact, penExtraAttributes));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, squareSize.Width, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line BC from point B to C and apply maximum (0.9f) pressure as the pen draw between the points
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, 0, squareSize.Height, TimeSpan.Zero, new PenInfo {
                Pressure = 0.9f
            }));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line CD from point C to D and keep the maximum pressure by not changing the pressure attribute
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, -squareSize.Width, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line DA from point D to A and reduce the pressure to minimum (0.1f) as the pen draw between the points
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, 0, -squareSize.Height, TimeSpan.Zero, new PenInfo {
                Pressure = 0.1f
            }));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            newStickyNoteSession.PerformActions(new List <ActionSequence> {
                sequence
            });

            try
            {
                var result = newStickyNoteSession.FindElementByAccessibilityId("RichEditBox");
                Assert.Fail("RichEditBox should not be defined anymore after a pen input is successfully performed.");
            }
            catch { }
        }
Esempio n. 8
0
        public void TapTest2()
        {
            //process ID
            Activate(3316);

            // Draw a circle with radius 300 and 40 (x, y) points
            const int radius = 300;
            const int points = 40;

            // Draw the circle with a single touch actions
            PointerInputDevice touchContact  = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touchContact, 0);

            //touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, 0, -radius, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerMove(paintCanvas, 0, -radius, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 0, 0, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));

            //touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            //for (double angle = 0; angle <= 2 * Math.PI; angle += 2 * Math.PI / points)
            //{
            //    //touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero));

            //    touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero));

            //    //touchSequence.AddAction(touchContact.CreatePointerMove(paintCanvas, 0, -radius, TimeSpan.Zero));
            //}
            //touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));

            touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 1, 1, TimeSpan.Zero));
            touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
            touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 400, 400, TimeSpan.Zero));
            touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
            //touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            //touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 400, 400, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
            //touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            //touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 400, 400, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));


            List <ActionSequence> actionList = new List <ActionSequence> {
                touchSequence
            };

            for (int i = 0; i < actionList.Count; i++)
            {
                Console.WriteLine(actionList[i].ToString());
            }
            session.PerformActions(actionList);
        }
Esempio n. 9
0
        public void DrawWithPen()
        {
            PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen);

            // Draw rectangle ABCD (consisting of AB, BC, CD, and DA lines)
            ActionSequence sequence = new ActionSequence(penDevice, 0);

            sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, B.X, B.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, C.X, C.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, D.X, D.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            // Fill the rectangle ABCD at the middle of the crosshair position (Point E)
            brushesPane.FindElementByAccessibilityId("FillBucket").Click();

            ActionSequence fillSequence = new ActionSequence(penDevice, 0);

            fillSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, E.Y, TimeSpan.Zero));
            fillSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            fillSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
            session.PerformActions(new List <ActionSequence> {
                fillSequence
            });

            // Erase by pressing PenEraser button along Point E X-Axis and Y-Axis to make the crosshair
            ActionSequence eraseSequence = new ActionSequence(penDevice, 0);

            eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X - 5, E.Y, TimeSpan.Zero));
            eraseSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenEraser));
            eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, B.X + 5, E.Y, TimeSpan.FromSeconds(.5)));
            eraseSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenEraser));
            eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, C.Y, TimeSpan.Zero));
            eraseSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenEraser));
            eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, B.Y, TimeSpan.FromSeconds(.5)));
            eraseSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenEraser));
            session.PerformActions(new List <ActionSequence> {
                eraseSequence
            });

            // Verify that the drawing operations took place
            Assert.IsTrue(undoButton.Displayed);
            Assert.IsTrue(undoButton.Enabled);
        }
Esempio n. 10
0
        public void Pen_Scroll_Horizontal()
        {
            // Different Alarm & Clock application version uses different UI elements
            if (AlarmTabClassName == "ListViewItem")
            {
                // The latest Alarms & Clock application no longer has horizontal scroll UI elements
            }
            else
            {
                WindowsElement homePagePivot       = session.FindElementByAccessibilityId("HomePagePivot");
                WindowsElement alarmPivotItem      = session.FindElementByAccessibilityId(AlarmTabAutomationId);
                WindowsElement worldClockPivotItem = session.FindElementByAccessibilityId(WorldClockTabAutomationId);
                Assert.IsNotNull(homePagePivot);
                Assert.IsNotNull(alarmPivotItem);
                Assert.IsNotNull(worldClockPivotItem);
                Assert.IsTrue(alarmPivotItem.Selected);
                Assert.IsFalse(worldClockPivotItem.Selected);

                // Perform scroll left pen action to switch from Alarm to WorldClock tab
                PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen);
                ActionSequence     sequence  = new ActionSequence(penDevice, 0);
                sequence.AddAction(penDevice.CreatePointerMove(homePagePivot, 0, 0, TimeSpan.Zero));
                sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
                sequence.AddAction(penDevice.CreatePointerMove(homePagePivot, -session.Manage().Window.Size.Width / 2, 0, TimeSpan.FromSeconds(.5)));
                sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
                session.PerformActions(new List <ActionSequence> {
                    sequence
                });

                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.IsFalse(alarmPivotItem.Selected);
                Assert.IsTrue(worldClockPivotItem.Selected);

                // Perform scroll right pen action to switch back from WorldClock to Alarm tab
                sequence = new ActionSequence(penDevice, 0);
                sequence.AddAction(penDevice.CreatePointerMove(homePagePivot, 0, 0, TimeSpan.Zero));
                sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
                sequence.AddAction(penDevice.CreatePointerMove(homePagePivot, session.Manage().Window.Size.Width / 2, 0, TimeSpan.FromSeconds(.5)));
                sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
                session.PerformActions(new List <ActionSequence> {
                    sequence
                });

                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.IsTrue(alarmPivotItem.Selected);
                Assert.IsFalse(worldClockPivotItem.Selected);
            }
        }
Esempio n. 11
0
        private void Tap(int xOffset, int yOffset)
        {
            System.Threading.Thread.Sleep(100);
            //the screenshot can take the place of sleeping instead

            Console.WriteLine("Tap start");
            PointerInputDevice touch         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touch, 0);

            touchSequence.AddAction(touch.CreatePointerMove(CoordinateOrigin.Pointer, xOffset, yOffset, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            List <ActionSequence> actions = new List <ActionSequence> {
                touchSequence
            };

            session.PerformActions(actions);

            if (record)
            {
                String eventFolder = installDirectory + "\\" + currentEventName;
                String filename    = eventFolder + "\\" + currentEventName + "_" + currentEventTapCount + ".png";
                currentEventTapCount++;
                Bitmap bmp = imageComparer.ScreenshotLockBits(width, height);
                bmp.Save(filename, ImageFormat.Png);
                bmp.Dispose();//doesn't work?
            }

            Console.WriteLine("Echo: " + actions[actions.Count - 1].ToString());
            Console.WriteLine("Tap end");
        }
Esempio n. 12
0
        private void Tap(int xOffset, int yOffset)
        {
            System.Threading.Thread.Sleep(100);
            //the screenshot can take the place of sleeping instead

            Console.WriteLine("Tap start");
            PointerInputDevice touch         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touch, 0);

            touchSequence.AddAction(touch.CreatePointerMove(CoordinateOrigin.Pointer, xOffset, yOffset, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            List <ActionSequence> actions = new List <ActionSequence> {
                touchSequence
            };

            session.PerformActions(actions);

            ////String filename = "Tap_" + System.DateTime.Now.ToString("yyyymmdd-HHmm-ssfff") + "_" + xOffset + "_" + yOffset + ".png";
            ////Bitmap bmp = imageComparer.ScreenshotLockBits(width, height);
            ////bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);


            Console.WriteLine("Echo: " + actions[actions.Count - 1].ToString());
            Console.WriteLine("Tap end");
        }
Esempio n. 13
0
        public void DrawBasicSquare()
        {
            Point canvasCoordinate = inkCanvas.Coordinates.LocationInViewport;
            Size  squareSize       = new Size(inkCanvas.Size.Width * 3 / 5, inkCanvas.Size.Height * 3 / 5);
            Point A = new Point(canvasCoordinate.X + inkCanvas.Size.Width / 5, canvasCoordinate.Y + inkCanvas.Size.Height / 5);

            // A        B
            //  ┌──────┐   Draw a basic ABCD square using Pen through the Actions API
            //  │      │   in viewport(default) origin mode:
            //  │      │   - X is absolute horizontal position in the session window
            //  └──────┘   - Y is absolute vertical position in the session window
            // D        C
            PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen);
            ActionSequence     sequence  = new ActionSequence(penDevice, 0);

            // Draw line AB from point A to B
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X + squareSize.Width, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line BC from point B to C
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X + squareSize.Width, A.Y + squareSize.Height, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line CD from point C to D
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y + squareSize.Height, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line DA from point D to A
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            newStickyNoteSession.PerformActions(new List <ActionSequence> {
                sequence
            });

            try
            {
                var result = newStickyNoteSession.FindElementByAccessibilityId("RichEditBox");
                Assert.Fail("RichEditBox should not be defined anymore after a pen input is successfully performed.");
            }
            catch { }
        }
Esempio n. 14
0
        public void Touch_DoubleClick()
        {
            WindowsElement appNameTitle   = FindAppTitleBar();
            WindowsElement maximizeButton = session.FindElementByAccessibilityId("Maximize");

            // Set focus on the application by switching window to itself
            session.SwitchTo().Window(session.CurrentWindowHandle);

            // Restore the application window if it is currently maximized
            if (!maximizeButton.Text.Contains("Maximize"))
            {
                maximizeButton.Click();
            }

            // Verify that window is currently not maximized
            Assert.IsTrue(maximizeButton.Text.Contains("Maximize"));

            // Perform touch double click action on the title bar to maximize the application window
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(appNameTitle, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(maximizeButton.Text.Contains("Maximize"));

            // Perform touch double click action on the title bar to restore the application window
            sequence = new ActionSequence(touchDevice, 0);
            sequence.AddAction(touchDevice.CreatePointerMove(appNameTitle, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(maximizeButton.Text.Contains("Maximize"));
        }
Esempio n. 15
0
        public void Touch_Click_OriginPointer()
        {
            WindowsElement alarmPivotItem      = session.FindElementByAccessibilityId("AlarmPivotItem");
            WindowsElement worldClockPivotItem = session.FindElementByAccessibilityId("WorldClockPivotItem");
            int            relativeX           = 0; // Initial x coordinate
            int            relativeY           = 0; // Initial y coordinate

            Assert.IsNotNull(alarmPivotItem);
            Assert.IsNotNull(worldClockPivotItem);
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);

            // Perform touch click action using pointer coordinate origin to switch from Alarm to WorldClock tab
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            relativeX = worldClockPivotItem.Location.X - relativeX;
            relativeY = worldClockPivotItem.Location.Y - relativeY;
            sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Pointer, relativeX, relativeY, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(alarmPivotItem.Selected);
            Assert.IsTrue(worldClockPivotItem.Selected);

            // Perform touch click action using pointer coordinate origin to switch from WorldClock to Alarm tab
            sequence  = new ActionSequence(touchDevice, 0);
            relativeX = alarmPivotItem.Location.X - relativeX;
            relativeY = alarmPivotItem.Location.Y - relativeY;
            sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Pointer, relativeX, relativeY, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);
        }
Esempio n. 16
0
        public static void DrawRectangle(WindowsDriver <WindowsElement> session)
        {
            OpenQA.Selenium.Appium.Interactions.PointerInputDevice penDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Pen);

            // Select the Brushes toolbox to have the Brushes Pane sidebar displayed and ensure that Marker is selected
            session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click();
            session.FindElementByAccessibilityId("SidebarWrapper").FindElementByAccessibilityId("PixelPencil3d").Click();

            // Locate the drawing surface
            WindowsElement inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper");

            Point    canvasCoordinate = inkCanvas.Coordinates.LocationInViewport;
            Size     squareSize       = new Size(inkCanvas.Size.Width * 3 / 5, inkCanvas.Size.Height * 3 / 5);
            Point    A       = new Point(canvasCoordinate.X + inkCanvas.Size.Width / 5, canvasCoordinate.Y + inkCanvas.Size.Height / 5);
            TimeSpan howFast = TimeSpan.FromMilliseconds(300.0);

            ActionSequence sequence = new ActionSequence(penDevice, 0);

            // Draw line AB from point A to B
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X + squareSize.Width, A.Y, howFast));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line BC from point B to C
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X + squareSize.Width, A.Y + squareSize.Height, howFast));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line CD from point C to D
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y + squareSize.Height, howFast));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            // Draw line DA from point D to A
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, A.X, A.Y, howFast));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));

            session.PerformActions(new List <ActionSequence> {
                sequence
            });
        }
Esempio n. 17
0
        public void Touch_Scroll_Horizontal()
        {
            WindowsElement homePagePivot       = session.FindElementByAccessibilityId("HomePagePivot");
            WindowsElement alarmPivotItem      = session.FindElementByAccessibilityId("AlarmPivotItem");
            WindowsElement worldClockPivotItem = session.FindElementByAccessibilityId("WorldClockPivotItem");

            Assert.IsNotNull(homePagePivot);
            Assert.IsNotNull(alarmPivotItem);
            Assert.IsNotNull(worldClockPivotItem);
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);

            // Perform scroll left touch action to switch from Alarm to WorldClock tab
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(homePagePivot, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerMove(homePagePivot, -session.Manage().Window.Size.Width / 2, 0, TimeSpan.FromSeconds(.5)));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(alarmPivotItem.Selected);
            Assert.IsTrue(worldClockPivotItem.Selected);

            // Perform scroll right touch action to switch back from WorldClock to Alarm tab
            sequence = new ActionSequence(touchDevice, 0);
            sequence.AddAction(touchDevice.CreatePointerMove(homePagePivot, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerMove(homePagePivot, session.Manage().Window.Size.Width / 2, 0, TimeSpan.FromSeconds(.5)));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);
        }
Esempio n. 18
0
        public void Touch_Click_OriginViewport()
        {
            WindowsElement alarmPivotItem      = session.FindElementByAccessibilityId("AlarmPivotItem");
            WindowsElement worldClockPivotItem = session.FindElementByAccessibilityId("WorldClockPivotItem");
            int            x = worldClockPivotItem.Location.X; // x coordinate of UI element relative to application window
            int            y = worldClockPivotItem.Location.Y; // y coordinate of UI element relative to application window

            Assert.IsNotNull(alarmPivotItem);
            Assert.IsNotNull(worldClockPivotItem);
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);

            // Perform touch click action using viewport coordinate origin to switch from Alarm to WorldClock tab
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, x, y, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(alarmPivotItem.Selected);
            Assert.IsTrue(worldClockPivotItem.Selected);

            // Perform touch click action using viewport coordinate origin to switch from WorldClock to Alarm tab
            sequence = new ActionSequence(touchDevice, 0);
            x        = alarmPivotItem.Location.X;
            y        = alarmPivotItem.Location.Y;
            sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, x, y, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);
        }
Esempio n. 19
0
 public void DrawCircle(PointerInputDevice penDevice, ActionSequence sequence, int centerX, int centerY, int radius, int stepSize)
 {
     sequence.AddAction(penDevice.CreatePointerMove(
                            CoordinateOrigin.Viewport,
                            centerX + radius,
                            centerY,
                            TimeSpan.Zero
                            ));
     sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
     for (int i = 0; i <= stepSize; i++)
     {
         sequence.AddAction(penDevice.CreatePointerMove(
                                CoordinateOrigin.Viewport,
                                Convert.ToInt32(centerX + radius * Math.Cos(2 * Math.PI * i / stepSize)),
                                Convert.ToInt32(centerY + radius * Math.Sin(2 * Math.PI * i / stepSize)),
                                TimeSpan.Zero
                                ));
     }
     sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
 }
Esempio n. 20
0
        private void DrawCircle()
        {
            // Draw a circle with radius 300 and 40 (x, y) points
            const int radius = 300;
            const int points = 40;

            // Select the Brushes toolbox to have the Brushes Pane sidebar displayed and ensure that Marker is selected
            session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click();
            session.FindElementByAccessibilityId("SidebarWrapper").FindElementByAccessibilityId("Marker3d").Click();

            // Locate the drawing surface
            WindowsElement inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper");
            //WindowsElement paintCanvas = session.FindElementByClassName("Afx:00007FF6908E0000:8");

            // Draw the circle with a single touch actions
            PointerInputDevice touchContact  = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touchContact, 0);

            //touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, 0, -radius, TimeSpan.Zero));
            //touchSequence.AddAction(touchContact.CreatePointerMove(paintCanvas, 0, -radius, TimeSpan.Zero));
            touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, 0, -radius, TimeSpan.Zero));
            touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));
            for (double angle = 0; angle <= 2 * Math.PI; angle += 2 * Math.PI / points)
            {
                //touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero));
                touchSequence.AddAction(touchContact.CreatePointerMove(CoordinateOrigin.Viewport, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero));
                //touchSequence.AddAction(touchContact.CreatePointerMove(paintCanvas, 0, -radius, TimeSpan.Zero));
            }
            touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));


            session.PerformActions(new List <ActionSequence> {
                touchSequence
            });

            // Verify that the drawing operations took place
            WindowsElement undoButton = session.FindElementByAccessibilityId("UndoIcon");

            Assert.IsTrue(undoButton.Displayed);
            Assert.IsTrue(undoButton.Enabled);
        }
Esempio n. 21
0
        private void Tap(int xOffset, int yOffset)
        {
            PointerInputDevice touch         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touch, 0);

            touchSequence.AddAction(touch.CreatePointerMove(zoomInteractor, xOffset, yOffset, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                touchSequence
            });
        }
Esempio n. 22
0
        public void Pen_Scroll_Vertical()
        {
            // Navigate to add alarm page
            session.FindElementByAccessibilityId("AddAlarmButton").Click();
            session.FindElementByAccessibilityId("AlarmTimePicker").Click();
            Thread.Sleep(TimeSpan.FromSeconds(1));

            WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector");
            WindowsElement minute00       = session.FindElementByName("00");

            Assert.IsNotNull(minuteSelector);
            Assert.IsNotNull(minute00);
            Assert.IsTrue(minute00.Displayed);

            // Perform scroll down pen action to scroll the minute hiding 00 minutes that was shown
            PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen);
            ActionSequence     sequence  = new ActionSequence(penDevice, 0);

            sequence.AddAction(penDevice.CreatePointerMove(minuteSelector, 0, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(minuteSelector, 0, -200, TimeSpan.FromSeconds(.5)));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(minute00.Displayed);

            // Perform scroll up pen action to scroll the the minute back showing 00 minutes that was hidden
            sequence = new ActionSequence(penDevice, 0);
            sequence.AddAction(penDevice.CreatePointerMove(minuteSelector, 0, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact));
            sequence.AddAction(penDevice.CreatePointerMove(minuteSelector, 0, 200, TimeSpan.FromSeconds(.5)));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(minute00.Displayed);
        }
Esempio n. 23
0
        public void DrawTwistingHurricane()
        {
            const int             LinesCount          = 10; // Paint application only supports up to 10 touch inputs
            List <ActionSequence> actionSequencesList = new List <ActionSequence>();

            // Draw N lines following a twisting & rotating radial pattern ressembling a hurricane eye
            double angle = 0;

            for (int line = 0; line < LinesCount; line++)
            {
                PointerInputDevice touchContact  = new PointerInputDevice(PointerKind.Touch);
                ActionSequence     touchSequence = new ActionSequence(touchContact, 0);

                int radius = 100;
                int x      = (int)(Math.Sin(angle) * radius);
                int y      = (int)(Math.Cos(angle) * radius);
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, x, -y, TimeSpan.Zero));
                touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));

                double subAngle = angle;
                while (radius < defaultRadius)
                {
                    x = (int)(Math.Sin(subAngle) * radius);
                    y = (int)(Math.Cos(subAngle) * radius);
                    touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, x, -y, TimeSpan.Zero));
                    radius   += 5;
                    subAngle += 2 * Math.PI / 36;
                }

                touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
                actionSequencesList.Add(touchSequence);
                angle += Math.PI / LinesCount;
            }

            session.PerformActions(actionSequencesList);

            // Verify that the drawing operations took place
            Assert.IsTrue(undoButton.Displayed);
            Assert.IsTrue(undoButton.Enabled);
        }
Esempio n. 24
0
        public void DrawFlower()
        {
            const int             LinesCount          = 10; // Paint application only supports up to 10 touch inputs
            List <ActionSequence> actionSequencesList = new List <ActionSequence>();

            // Draw N petals shape graph to create a flower like shape
            double angle = 0;

            for (int line = 0; line < LinesCount; line++)
            {
                OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
                ActionSequence touchSequence = new ActionSequence(touchContact, 0);

                int radius = 0;
                int x      = (int)(Math.Sin(angle) * (defaultRadius * Math.Cos(radius * 2 * Math.PI / 360)));
                int y      = (int)(Math.Cos(angle) * (defaultRadius * Math.Cos(radius * 2 * Math.PI / 360)));
                touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, x, -y, TimeSpan.Zero));
                touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact));

                double subAngle = angle;
                while (radius < defaultRadius)
                {
                    x = (int)(Math.Sin(subAngle) * (defaultRadius * Math.Cos(radius * 2 * Math.PI / 360)));
                    y = (int)(Math.Cos(subAngle) * (defaultRadius * Math.Cos(radius * 2 * Math.PI / 360)));
                    touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, x, -y, TimeSpan.Zero));
                    radius   += 5;
                    subAngle += 2 * Math.PI / 360;
                }

                touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact));
                actionSequencesList.Add(touchSequence);
                angle += 2 * Math.PI / LinesCount;
            }

            ourSession.PerformActions(actionSequencesList);

            // Verify that the drawing operations took place
            Assert.IsTrue(undoButton.Displayed);
            Assert.IsTrue(undoButton.Enabled);
        }
Esempio n. 25
0
        private void ActionsLaunch(String type)
        {
            int Y = 300;

            if (type.Contains("cmd"))
            {
                Y = 100;
            }
            else if (type.Contains("About"))
            {
                Y = 300;
            }
            else
            {
                Y = 650;
            }

            WindowsElement     plusTab   = session.FindElementByAccessibilityId("Console Window");
            PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence  = new ActionSequence(penDevice, 0);
            ActionSequence     sequence2 = new ActionSequence(penDevice, 0);

            sequence.AddAction(penDevice.CreatePointerMove(plusTab, 0, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, 0, 0, TimeSpan.Zero));
            sequence.AddAction(penDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(2000);
            sequence2.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, 0, Y, TimeSpan.Zero));
            sequence2.AddAction(penDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence2.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Pointer, 0, 1, TimeSpan.FromMilliseconds(50)));
            sequence2.AddAction(penDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence2
            });
        }
Esempio n. 26
0
        public void TapTest1()
        {
            PointerInputDevice touch         = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     touchSequence = new ActionSequence(touch, 0);

            touchSequence.AddAction(touch.CreatePointerMove(zoomInteractor, 0, 0, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerMove(zoomInteractor, 10, 0, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerMove(zoomInteractor, 20, 0, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerMove(zoomInteractor, 30, 0, TimeSpan.Zero));
            touchSequence.AddAction(touch.CreatePointerDown(PointerButton.TouchContact));
            touchSequence.AddAction(touch.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                touchSequence
            });
            Assert.IsTrue(true);
        }
Esempio n. 27
0
        public void Touch_Click_OriginElement()
        {
            var alarmPivotItem      = session.FindElementByAccessibilityId("AlarmPivotItem");
            var worldClockPivotItem = session.FindElementByAccessibilityId("WorldClockPivotItem");

            Assert.IsNotNull(alarmPivotItem);
            Assert.IsNotNull(worldClockPivotItem);
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);

            // Perform touch click action using element coordinate origin to switch from Alarm to WorldClock tab
            PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch);
            ActionSequence     sequence    = new ActionSequence(touchDevice, 0);

            sequence.AddAction(touchDevice.CreatePointerMove(worldClockPivotItem, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsFalse(alarmPivotItem.Selected);
            Assert.IsTrue(worldClockPivotItem.Selected);

            // Perform touch click action using element coordinate origin to switch from WorldClock to Alarm tab
            sequence = new ActionSequence(touchDevice, 0);
            sequence.AddAction(touchDevice.CreatePointerMove(alarmPivotItem, 0, 0, TimeSpan.Zero));
            sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
            sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
            session.PerformActions(new List <ActionSequence> {
                sequence
            });

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.IsTrue(alarmPivotItem.Selected);
            Assert.IsFalse(worldClockPivotItem.Selected);
        }
Esempio n. 28
0
 public void ActionsError_UnsupportedPointerType()
 {
     try
     {
         // Perform move action using unsupported pointer type
         PointerInputDevice penDevice = new PointerInputDevice((PointerKind)(-1));
         ActionSequence     sequence  = new ActionSequence(penDevice, 0);
         sequence.AddAction(penDevice.CreatePointerMove(alarmTabElement, 0, 0, TimeSpan.Zero));
         session.PerformActions(new List <ActionSequence> {
             sequence
         });
         Assert.Fail("Exception should have been thrown");
     }
     catch (InvalidOperationException) { }
 }
Esempio n. 29
0
 public void ActionsError_BadPointerMoveDuration()
 {
     try
     {
         // Perform pen move action using a bad duration value
         PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen);
         ActionSequence     sequence  = new ActionSequence(penDevice, 0);
         sequence.AddAction(penDevice.CreatePointerMove(CoordinateOrigin.Viewport, 0, 0, TimeSpan.FromMilliseconds(-1)));
         session.PerformActions(new List <ActionSequence> {
             sequence
         });
         Assert.Fail("Exception should have been thrown");
     }
     catch (InvalidOperationException exception)
     {
         Assert.AreEqual(ErrorStrings.ActionsArgumentDuration, exception.Message);
     }
 }
Esempio n. 30
0
 public void ActionsError_UnimplementedPointerType()
 {
     try
     {
         // Perform move action using unimplemented pointer type such as mouse
         PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Mouse);
         ActionSequence     sequence  = new ActionSequence(penDevice, 0);
         sequence.AddAction(penDevice.CreatePointerMove(alarmTabElement, 0, 0, TimeSpan.Zero));
         session.PerformActions(new List <ActionSequence> {
             sequence
         });
         Assert.Fail("Exception should have been thrown");
     }
     catch (InvalidOperationException exception)
     {
         Assert.IsTrue(exception.Message.StartsWith(ErrorStrings.ActionsUnimplementedPointerType));
     }
 }