diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/GitHub1776.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/GitHub1776.cs index 822e22c28767..3854be9c85d8 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/GitHub1776.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/GitHub1776.cs @@ -54,10 +54,10 @@ int CommandCount protected override void Init() { - PressedLabel = new Label(); - ReleasedLabel = new Label(); - ClickedLabel = new Label(); - CommandLabel = new Label(); + PressedLabel = new Label { AutomationId = "PressedLabel" }; + ReleasedLabel = new Label { AutomationId = "ReleasedLabel" }; + ClickedLabel = new Label { AutomationId = "ClickedLabel" }; + CommandLabel = new Label { AutomationId = "CommandLabel" }; var button = new Button { diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue2953.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue2953.cs index 9e5654df4713..1a60bc6ea07c 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue2953.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue2953.cs @@ -57,6 +57,7 @@ public HeaderCell() Height = 44; var label = new Label { BackgroundColor = Colors.Pink }; label.SetBinding(Label.TextProperty, "GroupName"); + label.SetBinding(Label.AutomationIdProperty, "GroupName"); View = label; } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8008.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8008.cs index 649d63784e02..e536abdfc49f 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8008.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8008.cs @@ -32,14 +32,12 @@ protected override void Init() }); item2.Title = "Visible After Remove"; -#pragma warning disable CS0618 // Type or member is obsolete -#pragma warning disable CS0612 // Type or member is obsolete - Device.BeginInvokeOnMainThread(() => + + MainThread.BeginInvokeOnMainThread(() => { this.Items.Remove(item1); }); -#pragma warning restore CS0612 // Type or member is obsolete -#pragma warning restore CS0618 // Type or member is obsolete + } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Github1776.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Github1776.cs index 91a0cde0ad05..daf90814e4f8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Github1776.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Github1776.cs @@ -1,5 +1,4 @@ -#if MACCATALYST -using NUnit.Framework; +using NUnit.Framework; using NUnit.Framework.Legacy; using UITest.Appium; using UITest.Core; @@ -14,17 +13,15 @@ public Github1776(TestDevice testDevice) : base(testDevice) public override string Issue => "Button Released not being triggered"; - // [Test] - // [Category(UITestCategories.Button)] - // public void GitHub1776Test() - // { - // App.WaitForElement(q => q.Marked("TheButton")); - // App.Tap(q => q.Marked("TheButton")); - - // Assert.AreEqual(1, _pressedCount, "Pressed should fire once per tap"); - // Assert.AreEqual(1, _releasedCount, "Released should fire once per tap"); - // Assert.AreEqual(1, _clickedCount, "Clicked should fire once per tap"); - // Assert.AreEqual(1, _commandCount, "Command should fire once per tap"); - // } + [Test] + [Category(UITestCategories.Button)] + public void GitHub1776Test() + { + App.WaitForElement("TheButton"); + App.Tap("TheButton"); + Assert.That(App.FindElement("PressedLabel").GetText(), Is.EqualTo("Pressed: 1")); + Assert.That(App.FindElement("ReleasedLabel").GetText(), Is.EqualTo("Released: 1")); + Assert.That(App.FindElement("ClickedLabel").GetText(), Is.EqualTo("Clicked: 1")); + Assert.That(App.FindElement("CommandLabel").GetText(), Is.EqualTo("Command: 1")); + } } -#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue12320.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue12320.cs index b7240590cc7a..07907eb9ca98 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue12320.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue12320.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_CATALYST // In the Catalyst App, the TapBackArrow() function does not work when the back button icon is replaced with a new image on the navigation page. +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -12,13 +13,13 @@ public Issue12320(TestDevice testDevice) : base(testDevice) public override string Issue => "[iOS] TabBarIsVisible = True/False doesn't work on Back Navigation When using BackButtonBehavior"; - // Where does TapBackArrow come from? - // [Test] - // [Category(UITestCategories.Shell)] - // public void PopLogicExecutesWhenUsingBackButtonBehavior() - // { - // App.WaitForElement("TestReady"); - // base.TapBackArrow(); - // App.WaitForElement("Tab 1"); - // } -} \ No newline at end of file + [Test] + [Category(UITestCategories.Shell)] + public void PopLogicExecutesWhenUsingBackButtonBehavior() + { + App.WaitForElement("TestReady"); + App.TapBackArrow(); + App.WaitForElement("Tab 1"); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2953.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2953.cs index d58aed568090..8031b9ed01c3 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2953.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2953.cs @@ -12,16 +12,12 @@ public Issue2953(TestDevice testDevice) : base(testDevice) public override string Issue => "GroupHeaderCells disappear when item is removed from a group in ListView (iOS only) "; - // [Test] - // [Category(UITestCategories.ListView)] - // [FailsOnIOS] - // public void Issue2953Test() - // { - // App.Screenshot("I am at Issue 2953"); - // App.WaitForElement(q => q.Marked("Header 3")); - // App.Screenshot("I see the Header 3"); - // App.Tap(q => q.Marked("btnRemove")); - // App.WaitForElement(q => q.Marked("Header 3")); - // App.Screenshot("I still see the Header 3"); - // } + [Test] + [Category(UITestCategories.ListView)] + public void Issue2953Test() + { + App.WaitForElement("Header 3"); + App.Tap("btnRemove"); + App.WaitForElement("Header 3"); + } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8008.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8008.cs index bbf1cca39426..fcf4374c9174 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8008.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8008.cs @@ -12,11 +12,10 @@ public Issue8008(TestDevice testDevice) : base(testDevice) public override string Issue => "Removing Shell Item can cause Shell to try and set a MenuItem as the default visible item"; - //[Test] - //[Category(UITestCategories.Shell)] - //[FailsOnIOS] - //public void RemovingShellItemCorrectlyPicksNextValidShellItemAsVisibleShellItem() - //{ - // App.WaitForElement("Success"); - //} + [Test] + [Category(UITestCategories.Shell)] + public void RemovingShellItemCorrectlyPicksNextValidShellItemAsVisibleShellItem() + { + App.WaitForElement("Success"); + } } \ No newline at end of file diff --git a/src/TestUtils/src/UITest.Appium/AppiumApp.cs b/src/TestUtils/src/UITest.Appium/AppiumApp.cs index 99160df665bc..91a0d3634940 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumApp.cs @@ -90,7 +90,7 @@ public virtual IUIElement FindElement(IQuery query) #nullable disable public virtual IUIElement FindElementByText(string text) { - return AppiumQuery.ByXPath("//*[@text='" + text + "']").FindElement(this); + return AppiumQuery.ByXPath("//*[@text='" + text + "' or @Name='" + text + "']").FindElement(this); } #nullable enable @@ -101,7 +101,7 @@ public virtual IReadOnlyCollection FindElements(string id) public virtual IReadOnlyCollection FindElementsByText(string text) { - return AppiumQuery.ByXPath("//*[@text='" + text + "']").FindElements(this); + return AppiumQuery.ByXPath("//*[@text='" + text + "' or @Name='" + text + "']").FindElements(this); } public virtual IReadOnlyCollection FindElements(IQuery query) diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index a63dd680ca38..4d89487aaaa1 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1679,6 +1679,26 @@ public static IList GetPerformanceData(this IApp app, string performance throw new InvalidOperationException($"Could not get the performance data"); } + /// + /// Navigates back in the application by simulating a tap on the platform-specific back navigation button. + /// + /// Represents the main gateway to interact with an app. + public static void TapBackArrow(this IApp app) + { + if (app is AppiumAndroidApp) + { + app.Tap(AppiumQuery.ByXPath("//android.widget.ImageButton[@content-desc='Navigate up']")); + } + else if (app is AppiumIOSApp || app is AppiumCatalystApp) + { + app.Tap(AppiumQuery.ByAccessibilityId("Back")); + } + else if (app is AppiumWindowsApp) + { + app.Tap(AppiumQuery.ByAccessibilityId("NavigationViewBackButton")); + } + } + static IUIElement Wait(Func query, Func satisfactory, string? timeoutMessage = null,