diff --git a/src/Controls/tests/UITests/Tests/BorderUITests.cs b/src/Controls/tests/UITests/Tests/BorderUITests.cs index 58b4d707ce2a..5e218610c210 100644 --- a/src/Controls/tests/UITests/Tests/BorderUITests.cs +++ b/src/Controls/tests/UITests/Tests/BorderUITests.cs @@ -32,7 +32,7 @@ public void BordersWithVariousShapes() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "BordersWithVariousShapes"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("WaitForStubControl"); diff --git a/src/Controls/tests/UITests/Tests/CarouselViewUITests.cs b/src/Controls/tests/UITests/Tests/CarouselViewUITests.cs index e9ebf60c13d6..830ba398d276 100644 --- a/src/Controls/tests/UITests/Tests/CarouselViewUITests.cs +++ b/src/Controls/tests/UITests/Tests/CarouselViewUITests.cs @@ -59,11 +59,11 @@ public void CarouselViewGoToNextCurrentItem() CheckLabelValue("lblPosition", index); CheckLabelValue("lblCurrentItem", index); - App.Click("btnNext"); + App.Tap("btnNext"); CheckLabelValue("lblPosition", nextIndex); CheckLabelValue("lblCurrentItem", nextIndex); CheckLabelValue("lblSelected", nextIndex); - App.Click("btnPrev"); + App.Tap("btnPrev"); } } diff --git a/src/Controls/tests/UITests/Tests/DragAndDropUITests.cs b/src/Controls/tests/UITests/Tests/DragAndDropUITests.cs index 1e13aef407c4..79f52dbe8c0d 100644 --- a/src/Controls/tests/UITests/Tests/DragAndDropUITests.cs +++ b/src/Controls/tests/UITests/Tests/DragAndDropUITests.cs @@ -32,7 +32,7 @@ public void DragEvents() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropEvents"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("LabelDragElement"); App.DragAndDrop("LabelDragElement", "DragTarget"); @@ -57,10 +57,10 @@ public void DragAndDropBetweenLayouts() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropBetweenLayouts"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("ResetButton"); - App.Click("ResetButton"); + App.Tap("ResetButton"); App.WaitForElement("Red"); App.WaitForElement("Green"); @@ -87,7 +87,7 @@ public void PlatformDragEventArgs() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropEventArgs"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("LabelDragElement"); App.DragAndDrop("LabelDragElement", "DragTarget"); @@ -172,9 +172,9 @@ public void DragStartEventCoordinates() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropBetweenLayouts"); - App.Click("GoButton"); + App.Tap("GoButton"); - App.Click("ResetButton"); + App.Tap("ResetButton"); App.WaitForElement("Blue"); App.WaitForElement("Green"); @@ -206,9 +206,9 @@ public void DragEventCoordinates() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropBetweenLayouts"); - App.Click("GoButton"); + App.Tap("GoButton"); - App.Click("ResetButton"); + App.Tap("ResetButton"); App.WaitForElement("Blue"); App.WaitForElement("Green"); @@ -245,9 +245,9 @@ public void DropEventCoordinates() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DragAndDropBetweenLayouts"); - App.Click("GoButton"); + App.Tap("GoButton"); - App.Click("ResetButton"); + App.Tap("ResetButton"); App.WaitForElement("Blue"); App.WaitForElement("Green"); diff --git a/src/Controls/tests/UITests/Tests/GestureRecognizerUITests.cs b/src/Controls/tests/UITests/Tests/GestureRecognizerUITests.cs index 8f227d42f3b0..5e56a8e1bb53 100644 --- a/src/Controls/tests/UITests/Tests/GestureRecognizerUITests.cs +++ b/src/Controls/tests/UITests/Tests/GestureRecognizerUITests.cs @@ -34,12 +34,12 @@ public void PointerGestureTest() App.WaitForElement("TargetView"); App.EnterText("TargetView", "PointerGestureRecognizerEvents"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("primaryLabel"); // using Tap in place of moving mouse for now - App.Click("primaryLabel"); - App.Click("secondaryLabel"); + App.Tap("primaryLabel"); + App.Tap("secondaryLabel"); var secondaryLabelText = App.FindElement("secondaryLabel").GetText(); Assert.IsNotEmpty(secondaryLabelText); @@ -51,10 +51,10 @@ public void DoubleTap() { App.WaitForElement("TargetView"); App.EnterText("TargetView", "DoubleTapGallery"); - App.Click("GoButton"); + App.Tap("GoButton"); App.WaitForElement("DoubleTapSurface"); - App.DoubleClick("DoubleTapSurface"); + App.DoubleTap("DoubleTapSurface"); var result = App.FindElement("DoubleTapResults").GetText(); Assert.AreEqual("Success", result); diff --git a/src/Controls/tests/UITests/Tests/Issues/GroupListViewHeaderIndexOutOfRange.cs b/src/Controls/tests/UITests/Tests/Issues/GroupListViewHeaderIndexOutOfRange.cs index a23e556dc79f..43b64f8e98e9 100644 --- a/src/Controls/tests/UITests/Tests/Issues/GroupListViewHeaderIndexOutOfRange.cs +++ b/src/Controls/tests/UITests/Tests/Issues/GroupListViewHeaderIndexOutOfRange.cs @@ -17,7 +17,7 @@ public GroupListViewHeaderIndexOutOfRange(TestDevice device) : base(device) public void GroupListViewHeaderIndexOutOfRangeTest() { App.WaitForElement(ButtonId); - App.Click(ButtonId); + App.Tap(ButtonId); App.WaitForElement(ButtonId); } } diff --git a/src/Controls/tests/UITests/Tests/Issues/HideSoftInputOnTappedPageTests.cs b/src/Controls/tests/UITests/Tests/Issues/HideSoftInputOnTappedPageTests.cs index 9c97b506508f..4a3a28131671 100644 --- a/src/Controls/tests/UITests/Tests/Issues/HideSoftInputOnTappedPageTests.cs +++ b/src/Controls/tests/UITests/Tests/Issues/HideSoftInputOnTappedPageTests.cs @@ -66,15 +66,15 @@ void HideSoftInputOnTappedPageTestForAndroidiOS(string control, bool hideOnTappe App.DismissKeyboard(); if (hideOnTapped) - App.Click("HideSoftInputOnTappedTrue"); + App.Tap("HideSoftInputOnTappedTrue"); else - App.Click("HideSoftInputOnTappedFalse"); + App.Tap("HideSoftInputOnTappedFalse"); - App.Click(control); + App.Tap(control); Assert.True(App.IsKeyboardShown()); - App.Click("EmptySpace"); + App.Tap("EmptySpace"); Assert.AreEqual(!hideOnTapped, App.IsKeyboardShown()); } finally @@ -137,19 +137,19 @@ public void TogglingHideSoftInputOnTappedForAndroidiOS() if (App.IsKeyboardShown()) App.DismissKeyboard(); - App.Click("HideSoftInputOnTappedFalse"); + App.Tap("HideSoftInputOnTappedFalse"); // Switch between enabling/disabling feature for (int i = 0; i < 2; i++) { - App.Click("HideKeyboardWhenTappingPage"); + App.Tap("HideKeyboardWhenTappingPage"); Assert.True(App.IsKeyboardShown()); - App.Click("EmptySpace"); + App.Tap("EmptySpace"); Assert.AreEqual(false, App.IsKeyboardShown()); - App.Click("DontHideKeyboardWhenTappingPage"); + App.Tap("DontHideKeyboardWhenTappingPage"); Assert.True(App.IsKeyboardShown()); - App.Click("EmptySpace"); + App.Tap("EmptySpace"); Assert.AreEqual(true, App.IsKeyboardShown()); } } diff --git a/src/Controls/tests/UITests/Tests/Issues/IsInvokeRequiredRaceCondition.cs b/src/Controls/tests/UITests/Tests/Issues/IsInvokeRequiredRaceCondition.cs index 7511e5832d61..8b3889eeadf1 100644 --- a/src/Controls/tests/UITests/Tests/Issues/IsInvokeRequiredRaceCondition.cs +++ b/src/Controls/tests/UITests/Tests/Issues/IsInvokeRequiredRaceCondition.cs @@ -16,7 +16,7 @@ public IsInvokeRequiredRaceCondition(TestDevice device) : base(device) public void ApplicationDispatcherIsInvokeRequiredRaceConditionCausesCrash() { App.WaitForElement("crashButton"); - App.Click("crashButton"); + App.Tap("crashButton"); App.WaitForElement("successLabel"); } } \ No newline at end of file diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue10234.cs b/src/Controls/tests/UITests/Tests/Issues/Issue10234.cs index 0def1328d44f..1aa72ae80d0b 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue10234.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue10234.cs @@ -20,17 +20,17 @@ public void ScrollCarouselViewAfterDispose() try { _ = App.WaitForElement("GoToTest"); - App.Click("GoToTest"); + App.Tap("GoToTest"); App.WaitForElement("goToShow"); - App.Click("goToShow"); + App.Tap("goToShow"); App.WaitForElement("goToBack"); ScrollNextItem(); - App.Click("goToBack"); + App.Tap("goToBack"); App.WaitForElement("goToShow"); - App.Click("goToShow"); + App.Tap("goToShow"); ScrollNextItem(); App.WaitForElement("goToBack"); - App.Click("goToBack"); + App.Tap("goToBack"); App.WaitForElement("goToShow"); } finally{ diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue10947.cs b/src/Controls/tests/UITests/Tests/Issues/Issue10947.cs index 79c433aef50f..f3f21cadf2de 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue10947.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue10947.cs @@ -22,13 +22,13 @@ public void CollectionViewHeaderShouldNotScroll() var footerEntry = App.WaitForElement(FooterEntry); var footerLocation = headerEntry.GetRect(); - App.Click(HeaderEntry); + App.Tap(HeaderEntry); var newHeaderEntry = App.WaitForElement(HeaderEntry); var newHeaderLocation = headerEntry.GetRect(); Assert.AreEqual(headerLocation, newHeaderLocation); - App.Click(FooterEntry); + App.Tap(FooterEntry); var newFooterEntry = App.WaitForElement(FooterEntry); var newFooterLocation = headerEntry.GetRect(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue11501.cs b/src/Controls/tests/UITests/Tests/Issues/Issue11501.cs index 958146af29a2..2a955b18231c 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue11501.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue11501.cs @@ -23,13 +23,13 @@ public void MakingFragmentRelatedChangesWhileAppIsBackgroundedFails(string scena try { App.WaitForElement(scenario); - App.Click(scenario); + App.Tap(scenario); App.WaitForElement("BackgroundMe"); App.BackgroundApp(); App.WaitForNoElement("BackgroundMe"); App.ForegroundApp(); App.WaitForElement("Restore"); - App.Click("Restore"); + App.Tap("Restore"); } catch { diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue12211.cs b/src/Controls/tests/UITests/Tests/Issues/Issue12211.cs index da9144f00cba..f0a0be7f5377 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue12211.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue12211.cs @@ -31,7 +31,7 @@ public void WhenChangingBoxViewOpacityThenValueIsCorrectlySet() string? ChangeOpacityAndGetCurrentStatus() { - App.Click(buttonId); + App.Tap(buttonId); return GetCurrentOpacityStatus(); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue14257.cs b/src/Controls/tests/UITests/Tests/Issues/Issue14257.cs index 67fae153df46..09fc3ce12447 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue14257.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue14257.cs @@ -15,13 +15,13 @@ public Issue14257(TestDevice device) : base(device) { } public void ResizeScrollViewAndTapButtonTest() { // Tapping the Resize button will change the height of the ScrollView content - App.Click("Resize"); + App.Tap("Resize"); // Scroll down to the Test button. When the bug is present, the button cannot be tapped. App.ScrollTo("Test"); App.WaitForElement("Test"); - App.Click("Test"); + App.Tap("Test"); // If we can successfully tap the button, the Success label will be displayed Assert.IsTrue(App.WaitForTextToBePresentInElement("Result", "Success")); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue15357.cs b/src/Controls/tests/UITests/Tests/Issues/Issue15357.cs index 29db79f79993..f9f990e6432f 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue15357.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue15357.cs @@ -33,7 +33,7 @@ public async Task WhenTapButtonThenListViewsChangesVisibility() string? TapButtonAndGetStatus() { - App.Click(buttonId); + App.Tap(buttonId); return GetStatus(); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue15826.cs b/src/Controls/tests/UITests/Tests/Issues/Issue15826.cs index 913b45a2a4cf..49876f55c4dd 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue15826.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue15826.cs @@ -33,7 +33,7 @@ public async Task WhenTapButtonThenListViewsChangesVisibility() string? TapButtonAndGetStatus() { - App.Click(buttonId); + App.Tap(buttonId); return GetStatus(); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue16320.cs b/src/Controls/tests/UITests/Tests/Issues/Issue16320.cs index fae11c7ecf77..32182130fa2e 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue16320.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue16320.cs @@ -24,7 +24,7 @@ public void Issue16320Test() TestDevice.Android }); - App.Click("Add"); + App.Tap("Add"); Assert.NotNull(App.WaitForElement("item: 1")); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue16386.cs b/src/Controls/tests/UITests/Tests/Issues/Issue16386.cs index 66ad7106910c..d8cf963e8a03 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue16386.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue16386.cs @@ -24,7 +24,7 @@ public void HittingEnterKeySendsDone() TestDevice.Windows, }); - App.Click("HardwareEnterKeyEntry"); + App.Tap("HardwareEnterKeyEntry"); App.SendKeys(66); App.WaitForElement("Success"); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue16561.cs b/src/Controls/tests/UITests/Tests/Issues/Issue16561.cs index 87886b62e1b2..cdc4cfebbab6 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue16561.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue16561.cs @@ -71,8 +71,8 @@ static void TapTwice(AppiumApp app, PointF point1, PointF point2) { // Windows will throw an error if we try to execute Taps with a TouchAction // or if we try to use ExecuteScript, so we'll just use TapCoordinates instead - app.Click(point1.X, point1.Y); - app.Click(point2.X, point2.Y); + app.TapCoordinates(point1.X, point1.Y); + app.TapCoordinates(point2.X, point2.Y); } else if (driver is IOSDriver) { diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue17400.cs b/src/Controls/tests/UITests/Tests/Issues/Issue17400.cs index 3c4ce40c42d1..965daf016d2c 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue17400.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue17400.cs @@ -20,7 +20,7 @@ public void Issue17400Test() "Is a Windows issue; see https://github.com/dotnet/maui/issues/17400"); App.WaitForElement("UpdateBtn"); - App.Click("UpdateBtn"); + App.Tap("UpdateBtn"); App.WaitForElement("WaitForStubControl"); VerifyScreenshot(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue17453.cs b/src/Controls/tests/UITests/Tests/Issues/Issue17453.cs index 79285278dfeb..51f56aa28395 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue17453.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue17453.cs @@ -32,10 +32,10 @@ public void EntryClearButtonWorksEntryDoesntClearWhenNotClickingOnClear() App.EnterText("RtlEntry", "Simple Text"); // Set focus - App.Click(rtlEntryRect.X, rtlEntryRect.Y); + App.TapCoordinates(rtlEntryRect.X, rtlEntryRect.Y); // Tap on the entry but not on the clear button - App.Click(rtlEntryRect.CenterX(), rtlEntryRect.CenterY()); + App.TapCoordinates(rtlEntryRect.CenterX(), rtlEntryRect.CenterY()); rtlEntryText = App.FindElement("RtlEntry").GetText(); @@ -63,11 +63,11 @@ public void EntryClearButtonWorks() var rtlEntryRect = App.FindElement("RtlEntry").GetRect(); // Set focus - App.Click(rtlEntryRect.X, rtlEntryRect.Y); + App.TapCoordinates(rtlEntryRect.X, rtlEntryRect.Y); // Tap Clear Button var margin = 30; - App.Click(rtlEntryRect.X + margin, rtlEntryRect.Y + margin); + App.TapCoordinates(rtlEntryRect.X + margin, rtlEntryRect.Y + margin); rtlEntryText = App.FindElement("RtlEntry").GetText(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue17694.cs b/src/Controls/tests/UITests/Tests/Issues/Issue17694.cs index c24ffd2382b5..c85ab917d8c2 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue17694.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue17694.cs @@ -25,7 +25,7 @@ public void Issue17694Test() App.WaitForElement("Spin"); // 1. Click button - App.Click("Spin"); + App.Tap("Spin"); VerifyScreenshot(); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18617.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18617.cs index 9f5b5bae4806..24f6a11f2d4b 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18617.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18617.cs @@ -19,14 +19,14 @@ public void CommandCanExecuteDisableButton() App.WaitForElement("WaitForStubControl"); // 1. Press the 'On' button. - App.Click("OnButton"); + App.Tap("OnButton"); // 2. The test fails if the 'On' button is still enabled or the 'Off' button is not enabled. var status1 = App.FindElement("StatusLabel").GetText(); Assert.AreEqual("OnButton disabled OffButton enabled", status1); // 3.Press the 'Off' button. - App.Click("OffButton"); + App.Tap("OffButton"); // 4. The test fails if the 'Off' button is still enabled or the 'On' button is not enabled. var status2 = App.FindElement("StatusLabel").GetText(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18675.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18675.cs index 70fe4ce0fa2e..d0b0914d1afd 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18675.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18675.cs @@ -19,7 +19,7 @@ public async Task EditorIsReadOnlyPreventModify() App.WaitForElement("WaitForStubControl"); // 1.The test fails if the placeholder text in the editor below is missing. - App.Click("IsReadOnlyEditor"); + App.Tap("IsReadOnlyEditor"); // Delay for the Editor underline on Android to return from // the selected state to normal state. diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18740.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18740.cs index 25f39f105279..aec9df5a8c73 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18740.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18740.cs @@ -25,7 +25,7 @@ public void Issue18740Test(string view) { // Navigate to the specific View test App.WaitForElement("WaitForStubControl"); - App.Click($"{view}Button"); + App.Tap($"{view}Button"); // 1.Make sure keyboard starts out closed. App.WaitForElement("WaitForStubControl"); @@ -33,7 +33,7 @@ public void Issue18740Test(string view) // 2. Focus the Entry. App.EnterText($"Test{view}", "test"); - App.Click($"Test{view}"); + App.Tap($"Test{view}"); // 3. Verify that the virtual keyboard appears. Assert.IsTrue(App.IsKeyboardShown()); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18754.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18754.cs index f9a4292e53ad..b563529246a2 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18754.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18754.cs @@ -20,13 +20,13 @@ public void Issue18754Test() App.WaitForElement("WaitForStubControl"); // 1. Attempt to enter any text into the editor below. - App.Click("ReadOnlyEditor"); + App.Tap("ReadOnlyEditor"); // 2. The test fails if the editor displays the input. Assert.IsFalse(App.IsKeyboardShown()); // 3. Attempt to edit the text in the editor below. - App.Click("FilledReadOnlyEditor"); + App.Tap("FilledReadOnlyEditor"); // 4. The test fails if the editor displays the input. Assert.IsFalse(App.IsKeyboardShown()); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19283.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19283.cs index aede24dfcb56..d40f54b91493 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19283.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19283.cs @@ -14,7 +14,7 @@ public Issue19283(TestDevice device) : base(device) { } [Category(UITestCategories.Button)] public void ButtonStillWorksWhenItHasPointerOverVSMSet() { - App.Click("btn"); + App.Tap("btn"); App.WaitForElement("Success"); } } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs index 51faa6023337..e648da80e9d5 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs @@ -17,7 +17,7 @@ public void RelativePointerPositionIsComputedCorrectly() { _ = App.WaitForElement("TapHere"); - App.Click("TapHere"); + App.Tap("TapHere"); App.WaitForElement("TapAccepted"); App.WaitForElement("Success"); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19379.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19379.cs index 11e77a4eccfe..0725ac59284d 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19379.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19379.cs @@ -21,7 +21,7 @@ public void UpdateCollectionViewHeaderTest() App.WaitForElement("WaitForStubControl"); // 1. Update the CollectionView Header. - App.Click("UpdateButton"); + App.Tap("UpdateButton"); // 2. Verify the result. VerifyScreenshot(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19509.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19509.cs index 3426ac05ad99..83741edb2e5a 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19509.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19509.cs @@ -18,8 +18,8 @@ public async Task EntryTextColorStopsWorkingAfterPropertyIsUpdatedFromBinding() App.WaitForElement("WaitForStubControl"); // 1. Click a button to update the text - App.Click("button"); - + App.Tap("button"); + await Task.Yield(); // 2. Verify that the Entry TextColor is correct (Green). diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19803.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19803.cs index 8d02cb5695a3..516a9f7788fa 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19803.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19803.cs @@ -20,7 +20,7 @@ public void NoNREWhenChangingGridItemsLayout() _ = App.WaitForElement("button"); //The test passes if no NullReferenceException is thrown - App.Click("button"); + App.Tap("button"); } } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19956.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19956.cs index 68b615b4ce2d..6b57823dfae9 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19956.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19956.cs @@ -39,7 +39,7 @@ public void ContentAccountsForStickyHeaders() scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); app.Driver.PerformActions([scrollSequence]); - app.Click("Entry12"); + App.Tap("Entry12"); ValidateEntryPosition("Entry12", app, stickyHeaderRect); ValidateEntryPosition("Entry1", app, stickyHeaderRect); ValidateEntryPosition("Entry2", app, stickyHeaderRect); @@ -68,12 +68,12 @@ public void BottomInsetsSetCorrectly() if (app is null) return; - app.Click("Entry5"); + App.Tap("Entry5"); ScrollToBottom(app); CheckForBottomEntry(app); KeyboardScrolling.NextiOSKeyboardPress(app.Driver); - app.Click("Entry10"); + App.Tap("Entry10"); ScrollToBottom(app); CheckForBottomEntry(app); KeyboardScrolling.NextiOSKeyboardPress(app.Driver); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue20439.cs b/src/Controls/tests/UITests/Tests/Issues/Issue20439.cs index ee1258355ae0..d7c804e337f4 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue20439.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue20439.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -20,11 +20,11 @@ public void ErrorShouldNotBeThrown() try { _ = App.WaitForElement("GoToTest"); - App.Click("GoToTest"); + App.Tap("GoToTest"); _ = App.WaitForElement("entry"); - App.Click("entry"); - App.Click("button"); + App.Tap("entry"); + App.Tap("button"); // The test passes if no crash is observed App.FindElement("editor"); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue20842.cs b/src/Controls/tests/UITests/Tests/Issues/Issue20842.cs index 8ee4897df5c4..d89d0f15e067 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue20842.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue20842.cs @@ -22,11 +22,11 @@ public async Task VerifyCollectionViewItemsAfterScrolling() App.WaitForElement(scrollUpButton); - App.Click(scrollDownButton); + App.Tap(scrollDownButton); await Task.Delay(200); - App.Click(scrollUpButton); + App.Tap(scrollUpButton); await Task.Delay(200); - App.Click(scrollDownButton); + App.Tap(scrollDownButton); await Task.Delay(500); VerifyScreenshot(); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue20903.cs b/src/Controls/tests/UITests/Tests/Issues/Issue20903.cs index e117ec656965..702f989a8c3e 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue20903.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue20903.cs @@ -16,12 +16,12 @@ public async Task RegisterTwoDoubleTapHandlersAndCheckNumberOfFiredEventsAsync() { _ = App.WaitForElement("AddDoubleTapHandlerButton"); - App.Click("AddDoubleTapHandlerButton"); - App.Click("AddDoubleTapHandlerButton"); + App.Tap("AddDoubleTapHandlerButton"); + App.Tap("AddDoubleTapHandlerButton"); - App.DoubleClick("MyLabel"); + App.DoubleTap("MyLabel"); await Task.Delay(500); - App.DoubleClick("MyLabel"); + App.DoubleTap("MyLabel"); // Wait for all event handler calls. await Task.Delay(1000); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue21609.cs b/src/Controls/tests/UITests/Tests/Issues/Issue21609.cs index 239e77157770..c60023cbf3c5 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue21609.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue21609.cs @@ -20,9 +20,9 @@ public void ChangingDimensionsOfCarouselViewDoesntUpdateItemDimensions() App.WaitForElement("ChangeCarouselViewDimensions"); var imageInitial = App.WaitForElement("DotnetBot").GetRect(); - App.Click("ChangeCarouselViewDimensions"); + App.Tap("ChangeCarouselViewDimensions"); var imageAfterSizeChange = App.WaitForElement("DotnetBot").GetRect(); - App.Click("ChangeCarouselViewDimensions"); + App.Tap("ChangeCarouselViewDimensions"); var imageAfterSizeChangedBacktoInitial = App.WaitForElement("DotnetBot").GetRect(); Assert.AreEqual(imageInitial, imageAfterSizeChangedBacktoInitial); diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue3525.cs b/src/Controls/tests/UITests/Tests/Issues/Issue3525.cs index 3f9a8c893044..d1270298f79d 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue3525.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue3525.cs @@ -32,11 +32,11 @@ public void SpanRegionClicking() var lineCenterOffset = lineHeight / 2; var y = location.Y; - App.Click(location.X + 10, y + lineCenterOffset); + App.TapCoordinates(location.X + 10, y + lineCenterOffset); - App.Click(location.X + 10, y + (lineHeight * 2) + lineCenterOffset); + App.TapCoordinates(location.X + 10, y + (lineHeight * 2) + lineCenterOffset); - App.Click(location.X + 10, y + (lineHeight * 4) + lineCenterOffset); + App.TapCoordinates(location.X + 10, y + (lineHeight * 4) + lineCenterOffset); App.WaitForTextToBePresentInElement(kClickCountAutomationId, $"{kClickCount}{1}"); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue5555.cs b/src/Controls/tests/UITests/Tests/Issues/Issue5555.cs index c735fc8f4c60..dcc5fa6b1e85 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue5555.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue5555.cs @@ -22,13 +22,13 @@ public void TableViewMemoryLeakWhenUsingSwitchCellOrEntryCell() }); App.WaitForElement("PushPage"); - App.Click("PushPage"); + App.Tap("PushPage"); App.WaitForElement("PushPage"); - App.Click("PushPage"); + App.Tap("PushPage"); App.WaitForElement("PushPage"); App.WaitForElement("CheckResult"); - App.Click("CheckResult"); + App.Tap("CheckResult"); App.WaitForElement("SuccessLabel"); } diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue5724.cs b/src/Controls/tests/UITests/Tests/Issues/Issue5724.cs index 4705168bed63..b465b8f864f5 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue5724.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue5724.cs @@ -24,11 +24,11 @@ public async Task TappingNextMovesToNextElement() }, "Send Keys only works on Android which is why we are ignoring these other platforms"); App.WaitForElement("Entry1"); - App.Click("Entry1"); + App.Tap("Entry1"); await Task.Yield(); - App.Click("SendNext"); + App.Tap("SendNext"); await Task.Yield(); Assert.True(App.IsFocused("Entry2")); @@ -45,11 +45,11 @@ public async Task TappingDoneClosesKeyboard() }, "Send Keys only works on Android which is why we are ignoring these other platforms"); App.WaitForElement("EntryDone"); - App.Click("EntryDone"); + App.Tap("EntryDone"); await Task.Yield(); Assert.True(App.IsKeyboardShown()); - App.Click("SendDone"); + App.Tap("SendDone"); await Task.Yield(); Assert.False(App.IsKeyboardShown()); } diff --git a/src/Controls/tests/UITests/Tests/Issues/RefreshViewTests.cs b/src/Controls/tests/UITests/Tests/Issues/RefreshViewTests.cs index 3163a5bd674b..b572fbc6c338 100644 --- a/src/Controls/tests/UITests/Tests/Issues/RefreshViewTests.cs +++ b/src/Controls/tests/UITests/Tests/Issues/RefreshViewTests.cs @@ -16,7 +16,7 @@ public RefreshViewTests(TestDevice device) [Category(UITestCategories.RefreshView)] public void IsRefreshingAndCommandTest() { - App.Click("ToggleRefresh"); + App.Tap("ToggleRefresh"); Assert.IsTrue(App.WaitForTextToBePresentInElement("IsRefreshingLabel", "IsRefreshing: True")); Assert.IsTrue(App.WaitForTextToBePresentInElement("IsRefreshingLabel", "IsRefreshing: False")); } diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla28570.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla28570.cs index 8d8f5d96f20e..c702ad743d36 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla28570.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla28570.cs @@ -23,7 +23,7 @@ public void Bugzilla28570Test() App.WaitForElement ("Tap"); App.Screenshot ("At test page"); - App.Click ("Tap"); + App.Tap("Tap"); App.WaitForElement ("28570Target"); } diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla41415.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla41415.cs index fdf244de960e..cb4333674d40 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla41415.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla41415.cs @@ -24,12 +24,12 @@ public void Bugzilla41415Test() "This test is failing, likely due to product issue"); App.WaitForElement(ButtonId); - App.Click(ButtonId); + App.Tap(ButtonId); App.WaitForNoElement("x: 100"); App.WaitForNoElement("y: 100"); App.WaitForNoElement("z: True", timeout: TimeSpan.FromSeconds(25)); App.WaitForNoElement("a: True"); - App.Click(ButtonId); + App.Tap(ButtonId); App.WaitForNoElement("x: 200"); App.WaitForNoElement("y: 100"); App.WaitForNoElement("z: True", timeout: TimeSpan.FromSeconds(25)); diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla44461.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla44461.cs index 3f9b355bdf10..232582e97c3a 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla44461.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.Bugzilla44461.cs @@ -32,7 +32,7 @@ public void Bugzilla44461Test() var buttonId= $"{position}"; App.WaitForElement(buttonId); var initialPosition = App.FindElement(buttonId).GetRect(); - App.Click(buttonId); + App.Tap(buttonId); var finalPosition = App.FindElement(buttonId).GetRect(); return (initialPosition, finalPosition); } diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewDisableScroll.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewDisableScroll.cs index ceb9f26f8205..c3135c94349d 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewDisableScroll.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewDisableScroll.cs @@ -52,7 +52,7 @@ public void ScrollEnabled() App.WaitForElement(FirstItemMark); - App.Click(ToggleButtonMark); + App.Tap(ToggleButtonMark); // Waiting until merge https://github.com/dotnet/maui/pull/19181 //App.ScrollDown(ScrollViewMark); diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewIsEnabled.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewIsEnabled.cs index 8545b5958337..04cd48e1bffe 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewIsEnabled.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewIsEnabled.cs @@ -29,7 +29,7 @@ public void ScrollViewInitiallyEnabled() // 1. Enable the ScrollView. App.WaitForElement(InitiallyEnabled); - App.Click(InitiallyEnabled); + App.Tap(InitiallyEnabled); App.WaitForElement(FirstItem); App.WaitForElement(ScrollView); @@ -51,11 +51,11 @@ public void ScrollViewInitiallyEnabledThenDisabled() // 1. Enable the ScrollView. App.WaitForElement(InitiallyEnabled); - App.Click(InitiallyEnabled); + App.Tap(InitiallyEnabled); // 2. Disable the ScrollView. App.WaitForElement(ToggleButton); - App.Click(ToggleButton); + App.Tap(ToggleButton); // Scrolling should now be IsEnabled = false @@ -79,7 +79,7 @@ public void ScrollViewInitiallyNotEnabled() // 1. Disable the ScrollView. App.WaitForElement(InitiallyNotEnabled); - App.Click(InitiallyNotEnabled); + App.Tap(InitiallyNotEnabled); App.WaitForElement(FirstItem); App.WaitForElement(ScrollView); App.ScrollTo("Item10", true); @@ -99,11 +99,11 @@ public void ScrollViewInitiallyNotEnabledThenEnabled() // 1. Disable the ScrollView. App.WaitForElement(InitiallyNotEnabled); - App.Click(InitiallyNotEnabled); + App.Tap(InitiallyNotEnabled); // 2. Enable the ScrollView. App.WaitForElement(ToggleButton); - App.Click(ToggleButton); + App.Tap(ToggleButton); // Scrolling should now be IsEnabled = true diff --git a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewObjectDisposed.cs b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewObjectDisposed.cs index fef58de1f210..24698b62a117 100644 --- a/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewObjectDisposed.cs +++ b/src/Controls/tests/UITests/Tests/Issues/ScrollViewUITests.ScrollViewObjectDisposed.cs @@ -22,7 +22,7 @@ public void ScrollViewObjectDisposedTest() "This test is failing, likely due to product issue"); // 1. Tap the button. - App.Click("TestButtonId"); + App.Tap("TestButtonId"); // 2. Verify does not cause an exception. App.WaitForElement("Success"); diff --git a/src/Controls/tests/UITests/Tests/Issues/SoftInputExtensionsPageTests.cs b/src/Controls/tests/UITests/Tests/Issues/SoftInputExtensionsPageTests.cs index 5a66bbb87a94..86b32281712d 100644 --- a/src/Controls/tests/UITests/Tests/Issues/SoftInputExtensionsPageTests.cs +++ b/src/Controls/tests/UITests/Tests/Issues/SoftInputExtensionsPageTests.cs @@ -16,9 +16,9 @@ public void SoftInputExtensionsPageTest() { // Make sure the buttons appear on the screen. Task.Delay(1000).Wait(); - App.Click("ShowKeyboard"); + App.Tap("ShowKeyboard"); Assert.IsTrue(App.WaitForTextToBePresentInElement("Result", "True")); - App.Click("HideKeyboard"); + App.Tap("HideKeyboard"); Assert.IsTrue(App.WaitForTextToBePresentInElement("Result", "False")); } } diff --git a/src/Controls/tests/UITests/Tests/Issues/XFIssue2681.cs b/src/Controls/tests/UITests/Tests/Issues/XFIssue2681.cs index d6643e3bda7c..8305067b9cc2 100644 --- a/src/Controls/tests/UITests/Tests/Issues/XFIssue2681.cs +++ b/src/Controls/tests/UITests/Tests/Issues/XFIssue2681.cs @@ -19,9 +19,9 @@ public XFIssue2681(TestDevice device) : base(device) public void ListViewDoesntFreezeApp() { App.WaitForElement(NavigateToPage); - App.Click(NavigateToPage); + App.Tap(NavigateToPage); App.WaitForElement("3"); - App.Click("GoBack"); + App.Tap("GoBack"); } } } diff --git a/src/Controls/tests/UITests/Tests/Issues/_IssuesUITest.cs b/src/Controls/tests/UITests/Tests/Issues/_IssuesUITest.cs index 390782ceb052..779ea35ca49b 100644 --- a/src/Controls/tests/UITests/Tests/Issues/_IssuesUITest.cs +++ b/src/Controls/tests/UITests/Tests/Issues/_IssuesUITest.cs @@ -40,7 +40,7 @@ protected override void FixtureTeardown() try { this.Back(); - App.Click("GoBackToGalleriesButton"); + App.Tap("GoBackToGalleriesButton"); } catch (Exception e) { @@ -58,7 +58,7 @@ private void NavigateToIssue(string issue) App.EnterText("SearchBarGo", issue); App.WaitForElement("SearchButton"); - App.Click("SearchButton"); + App.Tap("SearchButton"); } } } \ No newline at end of file diff --git a/src/Controls/tests/UITests/Tests/KeyboardScrolling.cs b/src/Controls/tests/UITests/Tests/KeyboardScrolling.cs index f3bd9caf0905..b89eb7516150 100644 --- a/src/Controls/tests/UITests/Tests/KeyboardScrolling.cs +++ b/src/Controls/tests/UITests/Tests/KeyboardScrolling.cs @@ -34,7 +34,7 @@ static void RunScrollingTest(IApp app, string galleryName, bool isEditor) else app.EnterText("TargetView", "KeyboardScrollingEntriesPage"); - app.Click("GoButton"); + App.Tap("GoButton"); // Entries 6 - 14 hit a group of interesting areas on scrolling // depending on the type of iOS device. @@ -63,7 +63,7 @@ static void RunScrollingTest(IApp app, string galleryName, bool isEditor) static void ClickText(IApp app, string marked, bool isEditor, out bool didReachEndofPage) { - app.Click(marked); + app.Tap(marked); didReachEndofPage = CheckIfViewAboveKeyboard(app, marked, isEditor); if (didReachEndofPage) HideKeyboard(app, (app as AppiumApp)?.Driver, isEditor); @@ -128,10 +128,10 @@ internal static void EntryNextEditorScrollingTest(IApp app, string galleryName) { app.WaitForElement("TargetView"); app.EnterText("TargetView", "KeyboardScrollingEntryNextEditorPage"); - app.Click("GoButton"); + app.Tap("GoButton"); app.WaitForElement("Entry1"); - app.Click("Entry1"); + app.Tap("Entry1"); CheckIfViewAboveKeyboard(app, "Entry1", false); NextiOSKeyboardPress((app as AppiumApp)?.Driver); @@ -157,7 +157,7 @@ internal static void GridStarRowScrollingTest (IApp app) { var entry = $"Entry{i}"; app.WaitForElement(entry); - app.Click(entry); + app.Tap(entry); CheckIfViewAboveKeyboard(app, entry, false); HideKeyboard(app, (app as AppiumApp)?.Driver, false); } diff --git a/src/Controls/tests/UITests/Tests/LabelUITests.cs b/src/Controls/tests/UITests/Tests/LabelUITests.cs index 265111609736..8f3ca0558ce6 100644 --- a/src/Controls/tests/UITests/Tests/LabelUITests.cs +++ b/src/Controls/tests/UITests/Tests/LabelUITests.cs @@ -41,7 +41,7 @@ public void SpanTapped() // TODO: This will probably fail on desktops because the tap is in screen coordinates and the // view seems to either be in window or parent coordinates. var r = remote.GetView().GetRect(); - App.Click(r.X + (r.Height * 3), r.CenterY()); // 3 "heights" in from the left + App.TapCoordinates(r.X + (r.Height * 3), r.CenterY()); // 3 "heights" in from the left var textAfterClick = remote.GetEventLabel().GetText(); Assert.AreEqual("Event: SpanTapped (fired 1)", textAfterClick); diff --git a/src/Controls/tests/UITests/Tests/ScrollViewUITests.cs b/src/Controls/tests/UITests/Tests/ScrollViewUITests.cs index 46e0217c7eba..7d450d9edda3 100644 --- a/src/Controls/tests/UITests/Tests/ScrollViewUITests.cs +++ b/src/Controls/tests/UITests/Tests/ScrollViewUITests.cs @@ -36,7 +36,7 @@ public void ScrollToElement1Start() App.WaitForElement("WaitForStubControl"); // 1. Tap a button to scroll to the start position. - App.Click("Start"); + App.Tap("Start"); App.WaitForNoElement("the scrollto button"); // 2. Verify that the scroll has moved to the correct position. @@ -58,7 +58,7 @@ public void ScrollToElement2Center() App.WaitForElement("WaitForStubControl"); // 1. Tap a button to scroll to the center position. - App.Click("Center"); + App.Tap("Center"); App.WaitForNoElement("the scrollto button"); // 2. Verify that the scroll has moved to the correct position. @@ -83,7 +83,7 @@ public void ScrollToElement3End() App.WaitForElement("WaitForStubControl"); // 1. Tap a button to scroll to the end. - App.Click("End"); + App.Tap("End"); // 2. Verify that the scroll has moved to the correct position. App.WaitForNoElement("the scrollto button"); @@ -104,7 +104,7 @@ public void ScrollToY() App.WaitForElement("WaitForStubControl"); // 1. Tap a button to scroll 100 px. - App.Click("Scroll100"); + App.Tap("Scroll100"); } else { @@ -122,11 +122,11 @@ public void ScrollToYTwice() App.WaitForElement("WaitForStubControl"); // 1. Tap a button to scroll 100 px. - App.Click("Scroll100"); + App.Tap("Scroll100"); App.WaitForNoElement("completed"); // 2. Repeat. - App.Click("Scroll100"); + App.Tap("Scroll100"); App.WaitForNoElement("completed"); } else diff --git a/src/Controls/tests/UITests/UtilExtensions.cs b/src/Controls/tests/UITests/UtilExtensions.cs index 33e46260bf8d..f6c2d484f23d 100644 --- a/src/Controls/tests/UITests/UtilExtensions.cs +++ b/src/Controls/tests/UITests/UtilExtensions.cs @@ -42,7 +42,7 @@ public static void NavigateTo(this IApp app, string text) { app.EnterText("SearchBar", text); } - app.Click(goToTestButtonId); + app.Tap(goToTestButtonId); app.WaitForNoElement(goToTestButtonId, "Timed out waiting for Go To Test button to disappear", TimeSpan.FromMinutes(1)); } @@ -54,7 +54,7 @@ public static void NavigateToIssues(this IApp app) app.WaitForElement("SearchBar"); app.ClearText("SearchBar"); - app.Click(goToTestButtonId); + app.Tap(goToTestButtonId); app.WaitForElement("TestCasesIssueList"); } diff --git a/src/Controls/tests/UITests/ViewContainers/BaseViewContainerRemote.cs b/src/Controls/tests/UITests/ViewContainers/BaseViewContainerRemote.cs index e02ed693b426..5c9cfb0719f5 100644 --- a/src/Controls/tests/UITests/ViewContainers/BaseViewContainerRemote.cs +++ b/src/Controls/tests/UITests/ViewContainers/BaseViewContainerRemote.cs @@ -55,14 +55,14 @@ public IReadOnlyCollection GetViews() public virtual void GoTo([CallerMemberName] string callerMemberName = "") { App.WaitForElement("TargetViewContainer"); - App.Click("TargetViewContainer"); + App.Tap("TargetViewContainer"); App.EnterText("TargetViewContainer", callerMemberName.Replace("_", "", StringComparison.OrdinalIgnoreCase) + "VisualElement"); - App.Click("GoButton"); + App.Tap("GoButton"); } public void TapView() { - App.Click(ViewQuery); + App.Tap(ViewQuery); } public T? GetProperty(BindableProperty formProperty) diff --git a/src/Controls/tests/UITests/ViewContainers/LayeredViewContainerRemote.cs b/src/Controls/tests/UITests/ViewContainers/LayeredViewContainerRemote.cs index dbc09f8feff1..1e88c85dddfd 100644 --- a/src/Controls/tests/UITests/ViewContainers/LayeredViewContainerRemote.cs +++ b/src/Controls/tests/UITests/ViewContainers/LayeredViewContainerRemote.cs @@ -17,7 +17,7 @@ public IUIElement GetLayeredLabel() public void TapHiddenButton() { - App.Click(LayeredHiddenButtonQuery); + App.Tap(LayeredHiddenButtonQuery); } } } \ No newline at end of file diff --git a/src/Controls/tests/UITests/ViewContainers/StateViewContainerRemote.cs b/src/Controls/tests/UITests/ViewContainers/StateViewContainerRemote.cs index 3f569fad09b8..703e538847eb 100644 --- a/src/Controls/tests/UITests/ViewContainers/StateViewContainerRemote.cs +++ b/src/Controls/tests/UITests/ViewContainers/StateViewContainerRemote.cs @@ -13,7 +13,7 @@ public StateViewContainerRemote(IUIClientContext? testContext, Enum formsType) public void TapStateButton() { App.Screenshot("Before state change"); - App.Click(StateButtonQuery); + App.Tap(StateButtonQuery); App.Screenshot("After state change"); } diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystMouseActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystMouseActions.cs new file mode 100644 index 000000000000..f48e7998683b --- /dev/null +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystMouseActions.cs @@ -0,0 +1,63 @@ +using OpenQA.Selenium.Appium; +using UITest.Core; + +namespace UITest.Appium +{ + public class AppiumCatalystMouseActions : ICommandExecutionGroup + { + const string DoubleClickCommand = "doubleClick"; + + readonly List _commands = new() + { + DoubleClickCommand, + }; + readonly AppiumApp _appiumApp; + + public AppiumCatalystMouseActions(AppiumApp appiumApp) + { + _appiumApp = appiumApp; + } + + public bool IsCommandSupported(string commandName) + { + return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase); + } + + public CommandResponse Execute(string commandName, IDictionary parameters) + { + return commandName switch + { + DoubleClickCommand => DoubleClick(parameters), + _ => CommandResponse.FailedEmptyResponse, + }; + } + + CommandResponse DoubleClick(IDictionary parameters) + { + var element = GetAppiumElement(parameters["element"]); + + if (element != null) + { + _appiumApp.Driver.ExecuteScript("macos: doubleClick", new Dictionary + { + { "elementId", element.Id }, + }); + } + return CommandResponse.SuccessEmptyResponse; + } + + static AppiumElement? GetAppiumElement(object element) + { + if (element is AppiumElement appiumElement) + { + return appiumElement; + } + else if (element is AppiumDriverElement driverElement) + { + return driverElement.AppiumElement; + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystPointerActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystTouchActions.cs similarity index 86% rename from src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystPointerActions.cs rename to src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystTouchActions.cs index 192e3881f886..408420dfc7e4 100644 --- a/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystPointerActions.cs +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystTouchActions.cs @@ -3,19 +3,19 @@ namespace UITest.Appium { - public class AppiumCatalystPointerActions : ICommandExecutionGroup + public class AppiumCatalystTouchActions : ICommandExecutionGroup { - const string DoubleClickCommand = "doubleClick"; + const string DoubleTapCommand = "doubleTap"; const string DragAndDropCommand = "dragAndDrop"; readonly List _commands = new() { - DoubleClickCommand, + DoubleTapCommand, DragAndDropCommand, }; readonly AppiumApp _appiumApp; - public AppiumCatalystPointerActions(AppiumApp appiumApp) + public AppiumCatalystTouchActions(AppiumApp appiumApp) { _appiumApp = appiumApp; } @@ -29,13 +29,13 @@ public CommandResponse Execute(string commandName, IDictionary p { return commandName switch { - DoubleClickCommand => DoubleClick(parameters), + DoubleTapCommand => DoubleTap(parameters), DragAndDropCommand => DragAndDrop(parameters), _ => CommandResponse.FailedEmptyResponse, }; } - CommandResponse DoubleClick(IDictionary parameters) + CommandResponse DoubleTap(IDictionary parameters) { var element = GetAppiumElement(parameters["element"]); diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSMouseActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSMouseActions.cs new file mode 100644 index 000000000000..26539bfe1166 --- /dev/null +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSMouseActions.cs @@ -0,0 +1,64 @@ +using OpenQA.Selenium.Appium; +using UITest.Core; + +namespace UITest.Appium +{ + public class AppiumIOSMouseActions : ICommandExecutionGroup + { + const string DoubleClickCommand = "doubleClick"; + + readonly List _commands = new() + { + DoubleClickCommand, + }; + readonly AppiumApp _appiumApp; + + public AppiumIOSMouseActions(AppiumApp appiumApp) + { + _appiumApp = appiumApp; + } + + public bool IsCommandSupported(string commandName) + { + return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase); + } + + public CommandResponse Execute(string commandName, IDictionary parameters) + { + return commandName switch + { + DoubleClickCommand => DoubleClick(parameters), + _ => CommandResponse.FailedEmptyResponse, + }; + } + + CommandResponse DoubleClick(IDictionary parameters) + { + var element = GetAppiumElement(parameters["element"]); + + if (element != null) + { + _appiumApp.Driver.ExecuteScript("mobile: doubleTap", new Dictionary + { + { "elementId", element.Id }, + }); + } + + return CommandResponse.SuccessEmptyResponse; + } + + static AppiumElement? GetAppiumElement(object element) + { + if (element is AppiumElement appiumElement) + { + return appiumElement; + } + else if (element is AppiumDriverElement driverElement) + { + return driverElement.AppiumElement; + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSPointerActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSTouchActions.cs similarity index 90% rename from src/TestUtils/src/UITest.Appium/Actions/AppiumIOSPointerActions.cs rename to src/TestUtils/src/UITest.Appium/Actions/AppiumIOSTouchActions.cs index 2cad7f1bc443..4d7e4c2a4140 100644 --- a/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSPointerActions.cs +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumIOSTouchActions.cs @@ -3,19 +3,19 @@ namespace UITest.Appium { - public class AppiumIOSPointerActions : ICommandExecutionGroup + public class AppiumIOSTouchActions : ICommandExecutionGroup { - const string DoubleClickCommand = "doubleClick"; + const string DoubleTapCommand = "doubleTap"; const string DragAndDropCommand = "dragAndDrop"; readonly List _commands = new() { - DoubleClickCommand, + DoubleTapCommand, DragAndDropCommand }; readonly AppiumApp _appiumApp; - public AppiumIOSPointerActions(AppiumApp appiumApp) + public AppiumIOSTouchActions(AppiumApp appiumApp) { _appiumApp = appiumApp; } @@ -29,13 +29,13 @@ public CommandResponse Execute(string commandName, IDictionary p { return commandName switch { - DoubleClickCommand => DoubleClick(parameters), + DoubleTapCommand => DoubleTap(parameters), DragAndDropCommand => DragAndDrop(parameters), _ => CommandResponse.FailedEmptyResponse, }; } - CommandResponse DoubleClick(IDictionary parameters) + CommandResponse DoubleTap(IDictionary parameters) { var element = GetAppiumElement(parameters["element"]); diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumMouseActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumMouseActions.cs new file mode 100644 index 000000000000..80608c23e4ac --- /dev/null +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumMouseActions.cs @@ -0,0 +1,219 @@ +using System.Drawing; +using OpenQA.Selenium; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Appium.Interactions; +using OpenQA.Selenium.Interactions; +using UITest.Core; + +namespace UITest.Appium +{ + public class AppiumMouseActions : ICommandExecutionGroup + { + const string ClickCommand = "click"; + const string ClickCoordinatesCommand = "clickCoordinates"; + const string DoubleClickCommand = "doubleClick"; + const string DoubleClickCoordinatesCommand = "doubleClickCoordinates"; + const string LongPressCommand = "longPress"; + + readonly AppiumApp _appiumApp; + + readonly List _commands = new() + { + ClickCommand, + ClickCoordinatesCommand, + DoubleClickCommand, + DoubleClickCoordinatesCommand, + LongPressCommand, + }; + + public AppiumMouseActions(AppiumApp appiumApp) + { + _appiumApp = appiumApp; + } + + public bool IsCommandSupported(string commandName) + { + return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase); + } + + public CommandResponse Execute(string commandName, IDictionary parameters) + { + return commandName switch + { + ClickCommand => Click(parameters), + ClickCoordinatesCommand => ClickCoordinates(parameters), + DoubleClickCommand => DoubleClick(parameters), + DoubleClickCoordinatesCommand => DoubleClickCoordinates(parameters), + LongPressCommand => LongPress(parameters), + _ => CommandResponse.FailedEmptyResponse, + }; + } + + CommandResponse Click(IDictionary parameters) + { + if (parameters.TryGetValue("element", out var val)) + { + AppiumElement? element = GetAppiumElement(parameters["element"]); + if (element == null) + { + return CommandResponse.FailedEmptyResponse; + } + return ClickElement(element); + } + else if (parameters.TryGetValue("x", out var x) && + parameters.TryGetValue("y", out var y)) + { + return ClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + } + + return CommandResponse.FailedEmptyResponse; + } + + CommandResponse DoubleClickCoordinates(IDictionary parameters) + { + if (parameters.TryGetValue("x", out var x) && + parameters.TryGetValue("y", out var y)) + { + return DoubleClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + } + + return CommandResponse.FailedEmptyResponse; + } + + CommandResponse ClickCoordinates(IDictionary parameters) + { + if (parameters.TryGetValue("x", out var x) && + parameters.TryGetValue("y", out var y)) + { + return ClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + } + + return CommandResponse.FailedEmptyResponse; + } + + CommandResponse ClickElement(AppiumElement element) + { + try + { + element.Click(); + return CommandResponse.SuccessEmptyResponse; + } + catch (InvalidOperationException) + { + return ProcessException(); + } + catch (WebDriverException) + { + return ProcessException(); + } + + CommandResponse ProcessException() + { + // Some elements aren't "clickable" from an automation perspective (e.g., Frame renders as a Border + // with content in it; if the content is just a TextBlock, we'll end up here) + + // All is not lost; we can figure out the location of the element in in the application window and Tap in that spot + PointF p = ElementToClickablePoint(element); + ClickCoordinates(p.X, p.Y); + return CommandResponse.SuccessEmptyResponse; + } + } + + CommandResponse ClickCoordinates(float x, float y) + { + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Mouse); + var sequence = new ActionSequence(touchDevice, 0); + sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, (int)x, (int)y, TimeSpan.FromMilliseconds(5))); + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { sequence }); + + return CommandResponse.SuccessEmptyResponse; + } + + CommandResponse DoubleClick(IDictionary parameters) + { + var element = GetAppiumElement(parameters["element"]); + + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Mouse); + var sequence = new ActionSequence(touchDevice, 0); + sequence.AddAction(touchDevice.CreatePointerMove(element, 0, 0, TimeSpan.FromMilliseconds(5))); + + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(250))); + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { sequence }); + + return CommandResponse.SuccessEmptyResponse; + } + + CommandResponse DoubleClickCoordinates(float x, float y) + { + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Mouse); + var sequence = new ActionSequence(touchDevice, 0); + sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, (int)x, (int)y, TimeSpan.FromMilliseconds(5))); + + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(250))); + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { sequence }); + + return CommandResponse.SuccessEmptyResponse; + } + + CommandResponse LongPress(IDictionary parameters) + { + var element = GetAppiumElement(parameters["element"]); + + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Mouse); + var longPress = new ActionSequence(touchDevice, 0); + + longPress.AddAction(touchDevice.CreatePointerMove(element, 0, 0, TimeSpan.FromMilliseconds(0))); + longPress.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + longPress.AddAction(touchDevice.CreatePointerMove(element, 0, 0, TimeSpan.FromMilliseconds(2000))); + longPress.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { longPress }); + + return CommandResponse.SuccessEmptyResponse; + } + + CommandResponse TapCoordinates(IDictionary parameters) + { + if (parameters.TryGetValue("x", out var x) && + parameters.TryGetValue("y", out var y)) + { + return ClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + } + + return CommandResponse.FailedEmptyResponse; + } + + static AppiumElement? GetAppiumElement(object element) + { + if (element is AppiumElement appiumElement) + { + return appiumElement; + } + else if (element is AppiumDriverElement driverElement) + { + return driverElement.AppiumElement; + } + + return null; + } + + static PointF ElementToClickablePoint(AppiumElement element) + { + string cpString = element.GetAttribute("ClickablePoint"); + string[] parts = cpString.Split(','); + float x = float.Parse(parts[0]); + float y = float.Parse(parts[1]); + + return new PointF(x, y); + } + } +} \ No newline at end of file diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumPointerActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumTouchActions.cs similarity index 75% rename from src/TestUtils/src/UITest.Appium/Actions/AppiumPointerActions.cs rename to src/TestUtils/src/UITest.Appium/Actions/AppiumTouchActions.cs index 7fd8b247d01b..889b44a81da2 100644 --- a/src/TestUtils/src/UITest.Appium/Actions/AppiumPointerActions.cs +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumTouchActions.cs @@ -3,34 +3,37 @@ using OpenQA.Selenium; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.Interactions; -using OpenQA.Selenium.Appium.MultiTouch; using OpenQA.Selenium.Interactions; using UITest.Core; namespace UITest.Appium { - public class AppiumPointerActions : ICommandExecutionGroup + public class AppiumTouchActions : ICommandExecutionGroup { - const string ClickCommand = "click"; - const string DoubleClickCommand = "doubleClick"; + const string TapCommand = "tap"; + const string TapCoordinatesCommand = "tapCoordinates"; + const string DoubleTapCommand = "doubleTap"; + const string DoubleTapCoordinatesCommand = "doubleTapCoordinates"; + const string TouchAndHoldCommand = "touchAndHold"; const string DragAndDropCommand = "dragAndDrop"; const string ScrollToCommand = "scrollTo"; - const string TapCoordinatesCommand = "tapCoordinates"; const string DragCoordinatesCommand = "dragCoordinates"; readonly AppiumApp _appiumApp; readonly List _commands = new() { - ClickCommand, - DoubleClickCommand, + TapCommand, + TapCoordinatesCommand, + DoubleTapCommand, + DoubleTapCoordinatesCommand, + TouchAndHoldCommand, DragAndDropCommand, ScrollToCommand, - TapCoordinatesCommand, DragCoordinatesCommand }; - public AppiumPointerActions(AppiumApp appiumApp) + public AppiumTouchActions(AppiumApp appiumApp) { _appiumApp = appiumApp; } @@ -44,17 +47,19 @@ public CommandResponse Execute(string commandName, IDictionary p { return commandName switch { - ClickCommand => Click(parameters), - DoubleClickCommand => DoubleClick(parameters), + TapCommand => Tap(parameters), + TapCoordinatesCommand => TapCoordinates(parameters), + DoubleTapCommand => DoubleTap(parameters), + DoubleTapCoordinatesCommand => DoubleTapCoordinates(parameters), + TouchAndHoldCommand => TouchAndHold(parameters), DragAndDropCommand => DragAndDrop(parameters), ScrollToCommand => ScrollTo(parameters), - TapCoordinatesCommand => TapCoordinates(parameters), DragCoordinatesCommand => DragCoordinates(parameters), _ => CommandResponse.FailedEmptyResponse, }; } - CommandResponse Click(IDictionary parameters) + CommandResponse Tap(IDictionary parameters) { if (parameters.TryGetValue("element", out var val)) { @@ -63,18 +68,18 @@ CommandResponse Click(IDictionary parameters) { return CommandResponse.FailedEmptyResponse; } - return ClickElement(element); + return TapElement(element); } else if (parameters.TryGetValue("x", out var x) && parameters.TryGetValue("y", out var y)) { - return ClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + return TapCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); } return CommandResponse.FailedEmptyResponse; } - CommandResponse ClickElement(AppiumElement element) + CommandResponse TapElement(AppiumElement element) { try { @@ -97,12 +102,12 @@ CommandResponse ProcessException() // All is not lost; we can figure out the location of the element in in the application window and Tap in that spot PointF p = ElementToClickablePoint(element); - ClickCoordinates(p.X, p.Y); + TapCoordinates(p.X, p.Y); return CommandResponse.SuccessEmptyResponse; } } - CommandResponse ClickCoordinates(float x, float y) + CommandResponse TapCoordinates(float x, float y) { OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); var sequence = new ActionSequence(touchDevice, 0); @@ -114,7 +119,7 @@ CommandResponse ClickCoordinates(float x, float y) return CommandResponse.SuccessEmptyResponse; } - CommandResponse DoubleClick(IDictionary parameters) + CommandResponse DoubleTap(IDictionary parameters) { var element = GetAppiumElement(parameters["element"]); @@ -132,6 +137,38 @@ CommandResponse DoubleClick(IDictionary parameters) return CommandResponse.SuccessEmptyResponse; } + CommandResponse DoubleTapCoordinates(float x, float y) + { + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); + var sequence = new ActionSequence(touchDevice, 0); + sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, (int)x, (int)y, TimeSpan.FromMilliseconds(5))); + + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(250))); + sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { sequence }); + + return CommandResponse.SuccessEmptyResponse; + } + + CommandResponse TouchAndHold(IDictionary parameters) + { + var element = GetAppiumElement(parameters["element"]); + + OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); + var longPress = new ActionSequence(touchDevice, 0); + + longPress.AddAction(touchDevice.CreatePointerMove(element, 0, 0, TimeSpan.FromMilliseconds(0))); + longPress.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); + longPress.AddAction(touchDevice.CreatePointerMove(element, 0, 0, TimeSpan.FromMilliseconds(2000))); + longPress.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); + _appiumApp.Driver.PerformActions(new List { longPress }); + + return CommandResponse.SuccessEmptyResponse; + } + CommandResponse DragAndDrop(IDictionary actionParams) { AppiumElement? sourceAppiumElement = GetAppiumElement(actionParams["sourceElement"]); @@ -215,7 +252,18 @@ CommandResponse TapCoordinates(IDictionary parameters) if (parameters.TryGetValue("x", out var x) && parameters.TryGetValue("y", out var y)) { - return ClickCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + return TapCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); + } + + return CommandResponse.FailedEmptyResponse; + } + + CommandResponse DoubleTapCoordinates(IDictionary parameters) + { + if (parameters.TryGetValue("x", out var x) && + parameters.TryGetValue("y", out var y)) + { + return DoubleTapCoordinates(Convert.ToSingle(x), Convert.ToSingle(y)); } return CommandResponse.FailedEmptyResponse; diff --git a/src/TestUtils/src/UITest.Appium/AppiumApp.cs b/src/TestUtils/src/UITest.Appium/AppiumApp.cs index 8038f00f58c8..91d792078391 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumApp.cs @@ -17,7 +17,8 @@ public AppiumApp(AppiumDriver driver, IConfig config) _config = config ?? throw new ArgumentNullException(nameof(config)); _commandExecutor = new AppiumCommandExecutor(); - _commandExecutor.AddCommandGroup(new AppiumPointerActions(this)); + _commandExecutor.AddCommandGroup(new AppiumMouseActions(this)); + _commandExecutor.AddCommandGroup(new AppiumTouchActions(this)); _commandExecutor.AddCommandGroup(new AppiumTextActions()); _commandExecutor.AddCommandGroup(new AppiumGeneralActions()); _commandExecutor.AddCommandGroup(new AppiumVirtualKeyboardActions(this)); diff --git a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs index d2f2fd135dc8..4abb5bcd7294 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs @@ -10,7 +10,8 @@ public class AppiumCatalystApp : AppiumApp, ICatalystApp public AppiumCatalystApp(Uri remoteAddress, IConfig config) : base(new MacDriver(remoteAddress, GetOptions(config)), config) { - _commandExecutor.AddCommandGroup(new AppiumCatalystPointerActions(this)); + _commandExecutor.AddCommandGroup(new AppiumCatalystMouseActions(this)); + _commandExecutor.AddCommandGroup(new AppiumCatalystTouchActions(this)); } public override ApplicationState AppState diff --git a/src/TestUtils/src/UITest.Appium/AppiumIOSApp.cs b/src/TestUtils/src/UITest.Appium/AppiumIOSApp.cs index ecf5a57e0628..b8f4872aa327 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumIOSApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumIOSApp.cs @@ -11,7 +11,8 @@ public class AppiumIOSApp : AppiumApp, IIOSApp public AppiumIOSApp(Uri remoteAddress, IConfig config) : base(new IOSDriver(remoteAddress, GetOptions(config)), config) { - _commandExecutor.AddCommandGroup(new AppiumIOSPointerActions(this)); + _commandExecutor.AddCommandGroup(new AppiumIOSMouseActions(this)); + _commandExecutor.AddCommandGroup(new AppiumIOSTouchActions(this)); _commandExecutor.AddCommandGroup(new AppiumIOSVirtualKeyboardActions(this)); } diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index b0e8e2f4db5d..e99caac17f61 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -18,7 +18,17 @@ public static class HelperExtensions /// https://github.com/dotnet/maui/issues/19754 /// /// Represents the main gateway to interact with an app. - /// Target Element + /// Target Element. + public static void Tap(this IApp app, string element) + { + app.FindElement(element).Click(); + } + + /// + /// Performs a mouse click on the matched element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. public static void Click(this IApp app, string element) { app.FindElement(element).Click(); @@ -58,6 +68,12 @@ public static Rectangle GetRect(this IUIElement element) throw new InvalidOperationException($"Could not get Rect of element"); } + /// + /// Enters text into the currently focused element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. + /// The text to enter. public static void EnterText(this IApp app, string element, string text) { var appElement = app.FindElement(element); @@ -65,11 +81,20 @@ public static void EnterText(this IApp app, string element, string text) app.DismissKeyboard(); } + /// + /// Hides soft keyboard if present. + /// + /// Represents the main gateway to interact with an app. public static void DismissKeyboard(this IApp app) { app.CommandExecutor.Execute("dismissKeyboard", ImmutableDictionary.Empty); } + /// + /// Whether or not the soft keyboard is shown. + /// + /// Represents the main gateway to interact with an app. + /// true if the soft keyboard is shown; otherwise, false. public static bool IsKeyboardShown(this IApp app) { var response = app.CommandExecutor.Execute("isKeyboardShown", ImmutableDictionary.Empty); @@ -100,21 +125,38 @@ public static void SendKeys(this IApp app, int keyCode, int metastate = 0) throw new InvalidOperationException($"SendKeys is not supported on {aaa.Driver}"); } + /// + /// Clears text from the currently focused element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. public static void ClearText(this IApp app, string element) { app.FindElement(element).Clear(); } + /// + /// Performs a mouse click on the matched element. + /// + /// Target Element. + public static void Click(this IUIElement element) + { + element.Command.Execute("click", new Dictionary() + { + { "element", element } + }); + } + /// /// For desktop, this will perform a mouse click on the target element. /// For mobile, this will tap the element. /// This API works for all platforms whereas TapCoordinates currently doesn't work on Catalyst /// https://github.com/dotnet/maui/issues/19754 /// - /// Target Element - public static void Click(this IUIElement element) + /// Target Element. + public static void Tap(this IUIElement element) { - element.Command.Execute("click", new Dictionary() + element.Command.Execute("tap", new Dictionary() { { "element", element } }); @@ -137,15 +179,98 @@ public static void Clear(this IUIElement element) }); } + /// + /// Performs a mouse double click on the matched element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. public static void DoubleClick(this IApp app, string element) { - var elementToClick = app.FindElement(element); + var elementToDoubleClick = app.FindElement(element); app.CommandExecutor.Execute("doubleClick", new Dictionary { - { "element", elementToClick }, + { "element", elementToDoubleClick }, + }); + } + + /// + /// Performs a mouse double click on the given coordinates. + /// + /// Represents the main gateway to interact with an app. + /// The x coordinate to double click. + /// The y coordinate to double click. + public static void DoubleClickCoordinates(this IApp app, float x, float y) + { + app.CommandExecutor.Execute("doubleClickCoordinates", new Dictionary + { + { "x", x }, + { "y", y } + }); + } + + /// + /// Performs two quick tap / touch gestures on the matched element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. + public static void DoubleTap(this IApp app, string element) + { + var elementToDoubleTap = app.FindElement(element); + app.CommandExecutor.Execute("doubleTap", new Dictionary + { + { "element", elementToDoubleTap }, + }); + } + + /// + /// Performs two quick tap / touch gestures on the given coordinates. + /// + /// Represents the main gateway to interact with an app. + /// The x coordinate to double tap. + /// The y coordinate to double tap. + public static void DoubleTapCoordinates(this IApp app, float x, float y) + { + app.CommandExecutor.Execute("doubleTapCoordinates", new Dictionary + { + { "x", x }, + { "y", y } + }); + } + + /// + /// Performs a long mouse click on the matched element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. + public static void LongPress(this IApp app, string element) + { + var elementToLongPress = app.FindElement(element); + app.CommandExecutor.Execute("longPress", new Dictionary + { + { "element", elementToLongPress }, }); } + /// + /// Performs a continuous touch gesture on the matched element. + /// + /// Represents the main gateway to interact with an app. + /// Target Element. + public static void TouchAndHold(this IApp app, string element) + { + var elementToTouchAndHold = app.FindElement(element); + app.CommandExecutor.Execute("touchAndHold", new Dictionary + { + { "element", elementToTouchAndHold }, + }); + } + + /// + /// Performs a long touch on an item, followed by dragging the item to a second item and dropping it. + /// + /// Represents the main gateway to interact with an app. + /// Element to be dragged. + /// Element to be dropped. public static void DragAndDrop(this IApp app, string dragSource, string dragTarget) { var dragSourceElement = app.FindElement(dragSource); @@ -158,6 +283,12 @@ public static void DragAndDrop(this IApp app, string dragSource, string dragTarg }); } + /// + /// Scroll until an element that matches the toElementId is shown on the screen. + /// + /// Represents the main gateway to interact with an app. + /// Specify what element to scroll within. + /// Whether scrolls should be down or up. public static void ScrollTo(this IApp app, string toElementId, bool down = true) { app.CommandExecutor.Execute("scrollTo", new Dictionary @@ -415,6 +546,21 @@ public static void SetOrientationPortrait(this IApp app) app.CommandExecutor.Execute("setOrientationPortrait", ImmutableDictionary.Empty); } + /// + /// Performs a mouse click on the given coordinates. + /// + /// Represents the main gateway to interact with an app. + /// The x coordinate to click. + /// The y coordinate to click. + public static void ClickCoordinates(this IApp app, float x, float y) + { + app.CommandExecutor.Execute("clickCoordinates", new Dictionary + { + { "x", x }, + { "y", y } + }); + } + /// /// Performs a tap / touch gesture on the given coordinates. /// This API currently doesn't work on Catalyst https://github.com/dotnet/maui/issues/19754