Example #1
0
        public void VariousSpanGesturePermutation()
        {
            RunningApp.WaitForElement($"{kGesture1}0");
            RunningApp.WaitForElement($"{kGesture2}0");
            var labelId = RunningApp.WaitForElement(kLabelAutomationId);
            var target  = labelId.First().Rect;


            for (int i = 1; i < 5; i++)
            {
                RunningApp.Tap($"TestSpan{i}");
                RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
                RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);


                RunningApp.WaitForElement($"{kGesture1}{i}");
                RunningApp.WaitForElement($"{kGesture2}{i}");
            }


            RunningApp.Tap($"TestSpan5");
            RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
            RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);

            RunningApp.WaitForElement($"{kGesture1}4");
            RunningApp.WaitForElement($"{kGesture2}4");
        }
Example #2
0
        public void Issue2577Test()
        {
            RunningApp.WaitForElement(NavButton);
            RunningApp.Tap(NavButton);

            RunningApp.WaitForElement(ToggleBackButton, retryFrequency: System.TimeSpan.FromSeconds(3));

            RunningApp.Screenshot("Hamburger menu icon is visible");

            AppResult[] items = RunningApp.Query(ArrowButton);
            Assert.AreNotEqual(items.Length, 0);
            RunningApp.Tap(ArrowButton);
            RunningApp.WaitForElement(MasterList);

            RunningApp.Screenshot("Flyout menu is showing");

            RunningApp.SwipeRightToLeft();
            RunningApp.WaitForNoElement(MasterList);

            RunningApp.Tap(ToggleBackButton);

            items = RunningApp.Query(ArrowButton);
            Assert.AreEqual(items.Length, 0);

            RunningApp.Screenshot("Back arrow is showing");

            var backArrow = RunningApp.Query(e => e.Class("Toolbar").Descendant("AppCompatImageButton")).Last();

            RunningApp.TapCoordinates(backArrow.Rect.CenterX, backArrow.Rect.CenterY);

            RunningApp.WaitForElement(NavButton);

            RunningApp.Screenshot("Back at first screen");
        }
        public void VerifyInputTransparent(string menuItem)
        {
            var results = RunningApp.WaitForElement(q => q.Marked(menuItem));

            if (results.Length > 1)
            {
                var rect = results.First(r => r.Class.Contains("Button")).Rect;

                RunningApp.TapCoordinates(rect.CenterX, rect.CenterY);
            }
            else
            {
                RunningApp.Tap(q => q.Marked(menuItem));
            }

            // Find the start label
            RunningApp.WaitForElement(q => q.Marked("Start"));

            // Find the control we're testing
            var result = RunningApp.WaitForElement(q => q.Marked(TargetAutomationId));
            var target = result.First().Rect;

            // Tap the control
            var y = target.CenterY;

            // In theory we want to tap the center of the control. But Stepper lays out differently than the other controls,
            // (it doesn't center vertically within its layout), so we need to adjust for it until someone fixes it
            if (menuItem == "Stepper")
            {
                y = target.Y;
            }

            RunningApp.TapCoordinates(target.CenterX, y);

            if (menuItem == nameof(DatePicker) || menuItem == nameof(TimePicker))
            {
                // These controls show a pop-up which we have to cancel/done out of before we can continue
#if __ANDROID__
                var cancelButtonText = "Cancel";
#elif __IOS__
                var cancelButtonText = "Done";
#else
                var cancelButtonText = "Cancel";
#endif
                RunningApp.WaitForElement(q => q.Marked(cancelButtonText));
                RunningApp.Tap(q => q.Marked(cancelButtonText));
            }

            // Since InputTransparent is set to false, the start label should not have changed
            RunningApp.WaitForElement(q => q.Marked("Start"));

            // Switch to InputTransparent == true
            RunningApp.Tap(q => q.Marked("Toggle"));

            // Tap the control
            RunningApp.TapCoordinates(target.CenterX, target.CenterY);

            // Since InputTransparent is set to true, the start label should now show a single tap
            RunningApp.WaitForElement(q => q.Marked("Taps registered: 1"));
        }
        public void VerifyTapBubbling(string menuItem, bool frameShouldRegisterTap)
        {
            var results = RunningApp.WaitForElement(q => q.Marked(menuItem));

            if (results.Length > 1)
            {
                var rect = results.First(r => r.Class.Contains("Button")).Rect;

                RunningApp.TapCoordinates(rect.CenterX, rect.CenterY);
            }
            else
            {
                RunningApp.Tap(q => q.Marked(menuItem));
            }

            // Find the start label
            RunningApp.WaitForElement(q => q.Marked(NoTaps));

            // Find the control we're testing
            var result = RunningApp.WaitForElement(q => q.Marked(TargetAutomationId));
            var target = result.First().Rect;

            // Tap the control
            var y = target.CenterY;
            var x = target.CenterX;

            // In theory we want to tap the center of the control. But Stepper lays out differently than the other controls,
            // so we need to adjust for it until someone fixes it
            if (menuItem == "Stepper")
            {
                y = target.Y + 5;
                x = target.X + 5;
            }

            RunningApp.TapCoordinates(x, y);

            if (menuItem == nameof(DatePicker) || menuItem == nameof(TimePicker))
            {
                // These controls show a pop-up which we have to cancel/done out of before we can continue
#if __ANDROID__
                var cancelButtonText = "Cancel";
                RunningApp.Back();
#elif __IOS__
                var cancelButtonText = "Done";
                RunningApp.WaitForElement(q => q.Marked(cancelButtonText));
                RunningApp.Tap(q => q.Marked(cancelButtonText));
#else
                var cancelButtonText = "DismissButton";
#endif
            }

            if (frameShouldRegisterTap)
            {
                RunningApp.WaitForElement(q => q.Marked(Tapped));
            }
            else
            {
                RunningApp.WaitForElement(q => q.Marked(NoTaps));
            }
        }
Example #5
0
        void TapOnPicker(int index)
        {
            var picker   = RunningApp.Query(q => q.TextField().Class("PickerEditText"))[index];
            var location = picker.Rect;

            RunningApp.TapCoordinates(location.X + 10, location.Y + location.Height / 2);
        }
Example #6
0
        void TapOnPicker(int index)
        {
            var picker   = GetPickerEditText(RunningApp)[index];
            var location = picker.Rect;

            RunningApp.TapCoordinates(location.X + 10, location.Y + location.Height / 2);
        }
Example #7
0
        public void VariousSpanGesturePermutation()
        {
            RunningApp.WaitForElement($"{kGesture1}0");
            RunningApp.WaitForElement($"{kGesture2}0");
            var labelId = RunningApp.WaitForElement(kLabelAutomationId);
            var target  = labelId.First().Rect;


            for (int i = 1; i < 5; i++)
            {
                RunningApp.Tap($"TestSpan{i}");

                // These tap retries work around a Tap Coordinate bug
                // with Xamarin.UITest >= 3.0.7
                int tapAttempts = 0;
                do
                {
                    RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
                    if (tapAttempts == 4)
                    {
                        RunningApp.WaitForElement($"{kGesture1}{i}");
                    }

                    tapAttempts++;
                } while (RunningApp.Query($"{kGesture1}{i}").Length == 0);

                tapAttempts = 0;

                do
                {
#if __WINDOWS__
                    RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
#else
                    RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
#endif
                    if (tapAttempts == 4)
                    {
                        RunningApp.WaitForElement($"{kGesture1}{i}");
                    }

                    tapAttempts++;
                } while (RunningApp.Query($"{kGesture2}{i}").Length == 0);
            }


            RunningApp.Tap($"TestSpan5");
            RunningApp.TapCoordinates(target.X + 5, target.Y + 5);

#if __WINDOWS__
            RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
#else
            RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
#endif


            RunningApp.WaitForElement($"{kGesture1}4");
            RunningApp.WaitForElement($"{kGesture2}4");
        }
Example #8
0
        public void ShapesPathReceiveGestureRecognizers()
        {
            var testLabel = RunningApp.WaitForFirstElement("LabelValue");

            Assert.AreEqual(ResetStatus, testLabel.ReadText());
            var pathRect = testLabel.Rect;

            RunningApp.TapCoordinates(pathRect.X + 100, pathRect.Y - 100);
            Assert.AreEqual(ClickedStatus, RunningApp.WaitForFirstElement("LabelValue").ReadText());
        }
Example #9
0
        public void ShapesPathReceiveGestureRecognizers()
        {
            var testLabel = RunningApp.WaitForFirstElement(StatusLabelId);

            Assert.AreEqual(ResetStatus, testLabel.ReadText());
            var testPath = RunningApp.WaitForFirstElement(PathId);
            var pathRect = testPath.Rect;

            RunningApp.TapCoordinates(pathRect.X + 1, pathRect.Y + 1);
            Assert.AreEqual(ClickedStatus, RunningApp.WaitForFirstElement(StatusLabelId).ReadText());
        }
        public void InvisibleTimepickerShowsDialogOnFocus()
        {
            RunningApp.WaitForElement(TimePickerButton);
            RunningApp.Screenshot("Issue 5159 page is showing in all it's glory");
            RunningApp.Tap(TimePickerButton);

            RunningApp.WaitForElement(x => x.Class("timePicker"));

            RunningApp.Screenshot("TimePicker is shown");
            RunningApp.TapCoordinates(5, 100);
        }
Example #11
0
        public void CascadeInputTransparentGrids()
        {
            RunningApp.WaitForElement(InnerGrid);
            RunningApp.Tap(InnerGrid);

            var green = RunningApp.WaitForElement(OuterGrid);

            RunningApp.TapCoordinates(green[0].Rect.CenterX, green[0].Rect.Y + 20);

            RunningApp.WaitForElement(Success);
        }
Example #12
0
        public void SpanRegionClicking()
        {
            var label    = RunningApp.WaitForElement(kLabelTestAutomationId);
            var location = label[0].Rect;

            var lineHeight = location.Height / 5;
            var y          = location.Y;

            RunningApp.TapCoordinates(location.X + 10, y + lineHeight / 2);
            RunningApp.TapCoordinates(location.X + 10, y + (lineHeight * 2) + lineHeight / 2);
            RunningApp.TapCoordinates(location.X + 10, y + (lineHeight * 4) + lineHeight / 2);
            RunningApp.WaitForElement($"{kClickCount}{1}");
        }
Example #13
0
        public void TestIsEnabledFalseContextActions()
        {
            var disable1 = RunningApp.Query(c => c.Marked("txtCellDisableContextActions1")) [0];

            Assert.IsFalse(disable1.Enabled);

            var screenBounds = RunningApp.RootViewRect();

            RunningApp.DragCoordinates(screenBounds.Width - 10, disable1.Rect.CenterY, 10, disable1.Rect.CenterY);

            RunningApp.Screenshot("Not showing context menu");
            RunningApp.WaitForNoElement(c => c.Marked("More"));
            RunningApp.TapCoordinates(screenBounds.CenterX, screenBounds.CenterY);
        }
Example #14
0
        public void TestDoesntCrashShowingContextMenu()
        {
            var screenBounds = RunningApp.Query(q => q.Raw("* index:0"))[0].Rect;

            var cell = RunningApp.Query(c => c.Marked("Swipe ME")) [0];

#if __IOS__
            RunningApp.DragCoordinates(screenBounds.Width - 10, cell.Rect.CenterY, 0, cell.Rect.CenterY);
            //TODO: fix this when context menu bug is fixed
            RunningApp.WaitForElement(c => c.Marked("Text4"));
#else
            RunningApp.TouchAndHoldCoordinates(cell.Rect.CenterX, cell.Rect.CenterY);
            RunningApp.WaitForElement(c => c.Marked("Text0"));
#endif
            RunningApp.Screenshot("Didn't crash");
            RunningApp.TapCoordinates(screenBounds.CenterX, screenBounds.CenterY);
        }
Example #15
0
        public void NavigatingBackToAlreadySelectedTopTabDoesntCrash()
        {
            var location = RunningApp.WaitForElement("Top 3")[0];

            RunningApp.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
            RunningApp.WaitForElement("TopTabPage3");
            RunningApp.Tap("Main 2");
            RunningApp.WaitForElement("TopTabPage2");
            RunningApp.Tap("Main 1");

            RunningApp.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
            RunningApp.WaitForElement("TopTabPage3");
            RunningApp.Tap("Main 2");
            RunningApp.WaitForElement("TopTabPage2");
            RunningApp.Tap("Main 1");
            RunningApp.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
            RunningApp.WaitForElement("TopTabPage3");
        }
Example #16
0
        public void VerifyInputTransparent(TestPoint test)
        {
            RunningApp.WaitForElement(q => q.Marked(test.AutomationId));
            RunningApp.Tap(test.AutomationId);

            // Determine the location of the button; we have to do this before adding the overlay because
            // otherwise the iOS UI tests won't be able to find it consistently
            var button = RunningApp.WaitForElement(DefaultButtonText);
            var coords = new Tuple <float, float>(button[0].Rect.CenterX, button[0].Rect.CenterY);

            // Add the overlay
            RunningApp.WaitForElement(AddOverlay);
            RunningApp.Tap(AddOverlay);

            // Now tap the screen at the Button's location
            // We can't do RunningApp.Tap(DefaultButtonText) because the UI tests on iOS can't see it
            RunningApp.TapCoordinates(coords.Item1, coords.Item2);

            // Check the results
            RunningApp.WaitForElement(test.ShouldBeTransparent ? Success : Running);
        }
Example #17
0
        public void Issue34007TestFirstElementHasLowestZOrder()
        {
            var buttonLocations = RunningApp.WaitForElement(q => q.Marked("Button 0"));

            var x = buttonLocations [0].Rect.CenterX;
            var y = buttonLocations [0].Rect.CenterY;

            // Button 1 was the last item added to the grid; it should be tappable
            RunningApp.Tap(q => q.Button("Button 1"));

            // The label should indicate that Button 1 was the last button tapped
            RunningApp.WaitForElement(q => q.Marked("Button 1 was tapped last"));

            RunningApp.Screenshot("Buttons Reordered");

            // Tapping Button1 1 reordered the buttons in the grid; Button 0 should
            // now be on top. Tapping at the Button 1 location should actually tap
            // Button 0, and the label should indicate that
            RunningApp.TapCoordinates(x, y);
            RunningApp.WaitForElement(q => q.Marked("Button 0 was tapped last"));

            RunningApp.Screenshot("Button 0 Tapped");
        }
Example #18
0
        public void TestIsEnabledFalseContextActions()
        {
            if (RunningApp is iOSApp)
            {
                var disable1 = RunningApp.Query(c => c.Marked("txtCellDisableContextActions1")) [0];
                Assert.IsFalse(disable1.Enabled);

                var screenBounds = RunningApp.Query(q => q.Raw("* index:0")) [0].Rect;

                if (RunningApp is iOSApp)
                {
                    RunningApp.DragCoordinates(screenBounds.Width - 10, disable1.Rect.CenterY, 10, disable1.Rect.CenterY);
                }
                else
                {
                    disable1 = RunningApp.Query(c => c.Marked("txtCellDisableContextActions1")) [0];
                    RunningApp.TouchAndHoldCoordinates(disable1.Rect.CenterX, disable1.Rect.CenterY);
                }
                RunningApp.Screenshot("Not showing context menu");
                RunningApp.WaitForNoElement(c => c.Marked("More"));
                RunningApp.TapCoordinates(screenBounds.CenterX, screenBounds.CenterY);
            }
        }