Skip to content

Commit

Permalink
[UI Testing] Split mouse and touch Appium actions and added pending o…
Browse files Browse the repository at this point in the history
…nes (TouchAndHold etc) (#21305)

* Split mouse and touch Appium actions

* More changes

* Fixes

* Fix build errors

* More changes

* Fix build errors

* More updates
  • Loading branch information
jsuarezruiz committed Apr 25, 2024
1 parent d92bebd commit abada83
Show file tree
Hide file tree
Showing 64 changed files with 714 additions and 171 deletions.
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/BorderUITests.cs
Expand Up @@ -32,7 +32,7 @@ public void BordersWithVariousShapes()
{
App.WaitForElement("TargetView");
App.EnterText("TargetView", "BordersWithVariousShapes");
App.Click("GoButton");
App.Tap("GoButton");

App.WaitForElement("WaitForStubControl");

Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/CarouselViewUITests.cs
Expand Up @@ -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");
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/Controls/tests/UITests/Tests/DragAndDropUITests.cs
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions src/Controls/tests/UITests/Tests/GestureRecognizerUITests.cs
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Expand Up @@ -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);
}
}
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
}
Expand Down
Expand Up @@ -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");
}
}
10 changes: 5 additions & 5 deletions src/Controls/tests/UITests/Tests/Issues/Issue10234.cs
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue10947.cs
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue11501.cs
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue12211.cs
Expand Up @@ -31,7 +31,7 @@ public void WhenChangingBoxViewOpacityThenValueIsCorrectlySet()

string? ChangeOpacityAndGetCurrentStatus()
{
App.Click(buttonId);
App.Tap(buttonId);

return GetCurrentOpacityStatus();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue14257.cs
Expand Up @@ -15,13 +15,13 @@ public class Issue14257 : _IssuesUITest
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"));
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue15357.cs
Expand Up @@ -33,7 +33,7 @@ public async Task WhenTapButtonThenListViewsChangesVisibility()

string? TapButtonAndGetStatus()
{
App.Click(buttonId);
App.Tap(buttonId);

return GetStatus();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue15826.cs
Expand Up @@ -33,7 +33,7 @@ public async Task WhenTapButtonThenListViewsChangesVisibility()

string? TapButtonAndGetStatus()
{
App.Click(buttonId);
App.Tap(buttonId);

return GetStatus();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue16320.cs
Expand Up @@ -24,7 +24,7 @@ public void Issue16320Test()
TestDevice.Android
});

App.Click("Add");
App.Tap("Add");

Assert.NotNull(App.WaitForElement("item: 1"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue16386.cs
Expand Up @@ -24,7 +24,7 @@ public void HittingEnterKeySendsDone()
TestDevice.Windows,
});

App.Click("HardwareEnterKeyEntry");
App.Tap("HardwareEnterKeyEntry");
App.SendKeys(66);
App.WaitForElement("Success");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue16561.cs
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue17400.cs
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/Controls/tests/UITests/Tests/Issues/Issue17453.cs
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue17694.cs
Expand Up @@ -25,7 +25,7 @@ public void Issue17694Test()
App.WaitForElement("Spin");

// 1. Click button
App.Click("Spin");
App.Tap("Spin");

VerifyScreenshot();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue18617.cs
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue18675.cs
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue18740.cs
Expand Up @@ -25,15 +25,15 @@ 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");
App.DismissKeyboard();

// 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());
Expand Down

0 comments on commit abada83

Please sign in to comment.