From 463ff0c1fafa3076e8d922a5dd918dcb88baef72 Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Mon, 18 Nov 2024 18:55:57 +0530 Subject: [PATCH 01/10] Migrated the Bugzilla45926, 52419, Issue10222 --- .../Tests/Issues/Bugzilla/Bugzilla45926.cs | 44 ++++++++++--------- .../Tests/Issues/Bugzilla/Bugzilla52419.cs | 41 +++++++++-------- .../Tests/Issues/Issue10222.cs | 15 +++---- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs index ef1033d21f3f..5a6b0f94e9d5 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs @@ -1,4 +1,6 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST +//TapBackArrow doesn't work on iOS and Mac. +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -10,26 +12,26 @@ public Bugzilla45926(TestDevice testDevice) : base(testDevice) { } - public override string Issue => "Effect not attaching to ScrollView"; + public override string Issue => "MessagingCenter prevents subscriber from being collected"; - // TODO Xamarin.UITest Migration - // [Test] - // [FailsOnAndroidWhenRunningOnXamarinUITest] - // public void Issue45926Test() - // { - // App.WaitForElement(q => q.Marked("New Page")); + [Test] + [Category(UITestCategories.Page)] + public void Issue45926Test() + { + App.WaitForElement("New Page"); - // App.Tap(q => q.Marked("New Page")); - // App.WaitForElement(q => q.Marked("Second Page #1")); - // App.Back(); - // App.WaitForElement(q => q.Marked("Intermediate Page")); - // App.Back(); - // App.Tap(q => q.Marked("Do GC")); - // App.Tap(q => q.Marked("Do GC")); - // App.Tap(q => q.Marked("Send Message")); - // App.Tap(q => q.Marked("Do GC")); + App.Tap("New Page"); + App.WaitForElement("Second Page #1"); + App.TapBackArrow(); + App.WaitForElement("Intermediate Page"); + App.TapBackArrow(); + App.Tap("Do GC"); + App.Tap("Do GC"); + App.Tap("Send Message"); + App.Tap("Do GC"); - // App.WaitForElement(q => q.Marked("Instances: 0")); - // App.WaitForElement(q => q.Marked("Messages: 0")); - // } -} \ No newline at end of file + App.WaitForElement("Instances: 0"); + App.WaitForElement("Messages: 0"); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs index 25cf3d903ba8..f3953cedbfea 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs @@ -1,4 +1,5 @@ -#if ANDROID +#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS +//TapBackArrow doesn't work on iOS and Mac. On the Android platform, tapping on Page 2 doesn't work. using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -13,25 +14,23 @@ public Bugzilla52419(TestDevice testDevice) : base(testDevice) public override string Issue => "[A] OnAppearing called for previous pages in a tab's navigation when switching active tabs"; - // [Test] - // [Category(UITestCategories.TabbedPage)] - // [FailsOnAndroidWhenRunningOnXamarinUITest] - // public void Bugzilla52419Test() - // { - // App.WaitForElement(q => q.Marked("Push new page")); - // App.Tap(q => q.Marked("Push new page")); - // App.WaitForElement(q => q.Marked("Push new page")); - // App.Tap(q => q.Marked("Push new page")); - // App.WaitForElement(q => q.Marked("Push new page")); - // App.Tap(q => q.Marked("Push new page")); - // App.Tap(q => q.Marked("Tab Page 2")); - // App.Tap(q => q.Marked("Tab Page 1")); - // App.Tap(q => q.Marked("Tab Page 2")); - // App.Tap(q => q.Marked("Tab Page 1")); - // App.Back(); - // App.WaitForElement(q => q.Marked("AppearanceLabel")); - // var label = App.Query(q => q.Marked("AppearanceLabel"))[0]; - // Assert.AreEqual("Times Appeared: 2", label.Text); - // } + [Test] + [Category(UITestCategories.TabbedPage)] + public void Bugzilla52419Test() + { + App.WaitForElement("Push new page"); + App.Tap("Push new page"); + App.WaitForElement("Push new page"); + App.Tap("Push new page"); + App.WaitForElement("Push new page"); + App.Tap("Push new page"); + App.Tap("Tab Page 2"); + App.Tap("Tab Page 1"); + App.Tap("Tab Page 2"); + App.Tap("Tab Page 1"); + App.TapBackArrow(); + App.WaitForElement("AppearanceLabel"); + Assert.That(App.WaitForElement("AppearanceLabel").GetText(), Is.EqualTo("Times Appeared: 2")); + } } #endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs index 9724773738f0..93e60c53b3d4 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_ANDROID +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -10,13 +11,10 @@ public Issue10222(TestDevice testDevice) : base(testDevice) { } - public override string Issue => "[Bug] Exception Ancestor must be provided for all pushes except first"; - - // Crash after navigation - /* + public override string Issue => "[CollectionView] ObjectDisposedException if the page is closed during scrolling"; + [Test] [Category(UITestCategories.LifeCycle)] - [Category(UITestCategories.Compatibility)] public void Issue10222Test() { App.WaitForElement("goTo"); @@ -24,6 +22,7 @@ public void Issue10222Test() App.WaitForElement("collectionView"); App.WaitForElement("goTo"); } - */ + } -} \ No newline at end of file +} +#endif \ No newline at end of file From 9344598bfe32567b07ded7c8a0750d33c5db9617 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:26:52 +0530 Subject: [PATCH 02/10] Migrated the Bugzilla 40005, 40173 and 43527 (#11) Co-authored-by: nivetha-nagalingam --- .../Issues/Bugzilla/Bugzilla40005.cs | 19 ++++++++- .../Issues/Bugzilla/Bugzilla40173.cs | 33 ++++++++++------ .../Issues/Bugzilla/Bugzilla43527.cs | 3 +- .../Tests/Issues/Bugzilla/Bugzilla40005.cs | 15 +++---- .../Tests/Issues/Bugzilla/Bugzilla40173.cs | 39 +++++++++---------- .../Tests/Issues/Bugzilla/Bugzilla43527.cs | 22 +++++------ 6 files changed, 75 insertions(+), 56 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs index bc8de454bb4c..8174c3f74ec9 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs @@ -12,6 +12,7 @@ public Bugzilla40005() : base(new MainPage()) public class MainPage : ContentPage { + public const string GoToPage1 = "Go to Page 1"; public const string GoToPage2 = "Go to Page 2"; public const string PageOneLabel = "Page 1"; public const string PageTwoLabel = "Page 2"; @@ -20,7 +21,23 @@ public class MainPage : ContentPage public MainPage() { - Application.Current.MainPage = new NavigationPage(new Page1()); + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = + { + new Button + { + AutomationId = GoToPage1, + Text = GoToPage1, + Command = new Command(() => + { + Navigation.PushAsync(new Page1()); + }) + } + } + }; } public class Page1 : ContentPage diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs index 841c21a8e761..05f6d98da4a5 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs @@ -78,22 +78,33 @@ protected override void Init() testListView.ItemsSource = items; testListView.ItemTemplate = new DataTemplate(() => { + + var grid = new Grid + { + HeightRequest = 60 + }; + + var itemLabel = new Label + { + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Start + }; + itemLabel.SetBinding(Label.TextProperty, "."); + var boxView = new BoxView + { + Color = Colors.Pink.MultiplyAlpha(0.5f) + }; + + grid.Children.Add(itemLabel); + grid.Children.Add(boxView); + var result = new ViewCell { - View = new Grid - { - Children = - { - new BoxView - { - AutomationId = ListTapTarget, - Color = Colors.Pink.MultiplyAlpha(0.5f) - } - } - } + View = grid }; return result; + }); testListView.ItemSelected += (sender, args) => outputLabel.Text = ListTapSuccessText; diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla43527.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla43527.cs index 061392008d9e..6927dd6cf63f 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla43527.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla43527.cs @@ -28,8 +28,7 @@ public TestPage() new Label { Text = "Hello Page" }, new Button { Text = "Change Title", AutomationId = "Change Title", Command = new Command(() => { - Title = $"New Title: {DateTime.Now.Second}"; - AutomationId = Title; + Title = "New Title"; }) } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs index 2a032fcb456b..5160f8e8141b 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs @@ -6,6 +6,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues { public class Bugzilla40005 : _IssuesUITest { + public const string GoToPage1 = "Go to Page 1"; public const string GoToPage2 = "Go to Page 2"; public const string PageOneLabel = "Page 1"; public const string PageTwoLabel = "Page 2"; @@ -15,23 +16,19 @@ public Bugzilla40005(TestDevice testDevice) : base(testDevice) } public override string Issue => "Navigation Bar back button does not show when using InsertPageBefore"; - - // Crashing when navigating - /* + [Test] [Category(UITestCategories.Navigation)] - [Category(UITestCategories.Compatibility)] - [FailsOnAndroidWhenRunningOnXamarinUITest] - [FailsOnIOSWhenRunningOnXamarinUITest] - [FailsOnMacWhenRunningOnXamarinUITest] public void Bugzilla40005Test() { + App.WaitForElement(GoToPage1); + App.Tap(GoToPage1); App.WaitForElement(PageOneLabel); App.Tap(GoToPage2); App.WaitForElement(PageTwoLabel); - App.Back(); + App.TapBackArrow(); App.WaitForElement(PageOneLabel); } - */ + } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs index df06014b85f7..5454b8c1a63f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs @@ -12,24 +12,23 @@ public Bugzilla40173(TestDevice testDevice) : base(testDevice) public override string Issue => "Android BoxView/Frame not clickthrough in ListView"; - // [FailsOnAndroidWhenRunningOnXamarinUITest] - // [FailsOnIOSWhenRunningOnXamarinUITest] - // [Test] - // [Category(UITestCategories.InputTransparent)] - // public void ButtonBlocked() - // { - // App.Tap("CantTouchButtonId"); - - // Assert.That(App.FindElement("outputlabel").GetText()? - // .Equals("Failed", StringComparison.OrdinalIgnoreCase), - // Is.False); - - // App.Tap("CanTouchButtonId"); - - // App.WaitForTextToBePresentInElement("outputlabel", "ButtonTapped"); - // #if !__MACOS__ - // App.Tap("ListTapTarget"); - // App.WaitForTextToBePresentInElement("outputlabel", "ItemTapped"); - // #endif - // } + [Test] + [Category(UITestCategories.InputTransparent)] + public void ButtonBlocked() + { + App.WaitForElement("CantTouchButtonId"); + App.Tap("CantTouchButtonId"); + + Assert.That(App.FindElement("outputlabel").GetText()? + .Equals("Failed", StringComparison.OrdinalIgnoreCase), + Is.False); + + App.Tap("CanTouchButtonId"); + + App.WaitForElement("ButtonTapped"); + + App.WaitForElement("Foo"); + App.Tap("Foo"); + App.WaitForElement("ItemTapped"); + } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla43527.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla43527.cs index 97f13f071f60..d2c4668a8a15 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla43527.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla43527.cs @@ -13,17 +13,13 @@ public Bugzilla43527(TestDevice testDevice) : base(testDevice) public override string Issue => "[UWP] Detail title does not update when wrapped in a NavigationPage"; - // [Test] - // [Category(UITestCategories.FlyoutPage)] - // public void TestB43527UpdateTitle() - // { - // // TODO from Xamarin.UITest migration - // // I'm not sure if this actually verifies the functionality here - // // we might need to add a VerifyScreenshot for this - // // And test is failing so disabled for now - // App.WaitForElement("Change Title"); - // App.WaitForElement("Test Page"); - // App.Tap("Change Title"); - // App.WaitForNoElement("Test Page"); - // } + [Test] + [Category(UITestCategories.FlyoutPage)] + public void TestB43527UpdateTitle() + { + App.WaitForElement("Change Title"); + App.WaitForElement("Test Page"); + App.Tap("Change Title"); + App.WaitForElement("New Title"); + } } \ No newline at end of file From cab19b201e8170e7bae82af7ee30a98acb95ac2e Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Thu, 21 Nov 2024 12:04:29 +0530 Subject: [PATCH 03/10] Updated the migrated issues --- .../Issues/Bugzilla/Bugzilla38731.cs | 41 ++++++++++-------- .../Issues/Bugzilla/Bugzilla40173.cs | 1 + .../Tests/Issues/Bugzilla/Bugzilla32040.cs | 15 +++---- .../Tests/Issues/Bugzilla/Bugzilla38731.cs | 43 ++++++++++--------- .../Tests/Issues/Bugzilla/Bugzilla39331.cs | 24 +++++------ 5 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs index c0dcbcb37ba3..9aaf6b5a0c84 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs @@ -2,30 +2,37 @@ namespace Maui.Controls.Sample.Issues; [Issue(IssueTracker.Bugzilla, 38731, "iOS.NavigationRenderer.GetAppearedOrDisappearedTask NullReferenceExceptionObject", PlatformAffected.iOS)] -public class Bugzilla38731 : TestContentPage +public class Bugzilla38731 : TestNavigationPage { protected override void Init() { - var label = new Label(); - label.Text = "Page one..."; - label.HorizontalTextAlignment = TextAlignment.Center; + Navigation.PushAsync(new PageOne()); + } - var button = new Button(); - button.AutomationId = "btn1"; - button.Text = "Navigate to page two"; - button.Clicked += Button_Clicked; + public class PageOne : ContentPage + { + public PageOne() + { + var label = new Label(); + label.Text = "Page one..."; + label.HorizontalTextAlignment = TextAlignment.Center; - var content = new StackLayout(); - content.Children.Add(label); - content.Children.Add(button); + var button = new Button(); + button.AutomationId = "btn1"; + button.Text = "Navigate to page two"; + button.Clicked += Button_Clicked; - Title = "Page one"; - Content = content; - } + var content = new StackLayout(); + content.Children.Add(label); + content.Children.Add(button); - void Button_Clicked(object sender, EventArgs e) - { - Navigation.PushAsync(new PageTwo()); + Title = "Page one"; + Content = content; + } + void Button_Clicked(object sender, EventArgs e) + { + Navigation.PushAsync(new PageTwo()); + } } public class PageTwo : ContentPage diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs index 05f6d98da4a5..b224d33aa1a4 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs @@ -94,6 +94,7 @@ protected override void Init() { Color = Colors.Pink.MultiplyAlpha(0.5f) }; + boxView.SetBinding(BoxView.AutomationIdProperty, "."); grid.Children.Add(itemLabel); grid.Children.Add(boxView); diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs index 44579281aae9..8155889ff13f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs @@ -1,4 +1,4 @@ -/* + using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -15,16 +15,13 @@ public Bugzilla32040(TestDevice testDevice) : base(testDevice) [Test] [Category(UITestCategories.Cells)] - [FailsOnIOSWhenRunningOnXamarinUITest] - [FailsOnWindowsWhenRunningOnXamarinUITest] public void TappedWorksForEntryAndSwithCellTest() - { + { App.WaitForElement("blahblah"); - App.Tap("blahblah"); - App.Tap("yaddayadda"); + App.Tap("blahblah"); + App.WaitForElement("Tapped"); - Assert.That(App.FindElements("Tapped").Count, - Is.GreaterThanOrEqualTo(2)); + App.Tap("Click Here"); + Assert.That(App.WaitForElement("yaddayadda").GetText(), Is.EqualTo("Tapped")); } } -*/ \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs index 45717daa6e88..d261dc144972 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs @@ -1,5 +1,4 @@ -#if IOS -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -13,24 +12,26 @@ public Bugzilla38731(TestDevice testDevice) : base(testDevice) public override string Issue => "iOS.NavigationRenderer.GetAppearedOrDisappearedTask NullReferenceExceptionObject"; - // [Test] - // [Category(UITestCategories.Navigation)] - // [FailsOnIOSWhenRunningOnXamarinUITest] - // public void Bugzilla38731Test () - // { - // App.WaitForElement("btn1"); - // App.Tap("btn1"); + [Test] + [Category(UITestCategories.Navigation)] + public void Bugzilla38731Test () + { + App.WaitForElement("btn1"); + App.Tap("btn1"); - // App.WaitForElement("btn2"); - // App.Tap("btn2"); + App.WaitForElement("btn2"); + App.Tap("btn2"); - // App.WaitForElement("btn3"); - // App.Tap("btn3"); - - // App.Back(); - // App.Back(); - // App.Back(); - // App.Back(); - // } -} -#endif \ No newline at end of file + App.WaitForElement("btn3"); + App.Tap("btn3"); +#if ANDROID && WINDOWS + App.TapBackArrow(); + App.TapBackArrow(); + App.TapBackArrow(); +#else + App.Back(); + App.Back(); + App.Back(); +#endif + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs index 30c3dffcddb2..aa96c312aca0 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs @@ -12,21 +12,17 @@ public Bugzilla39331(TestDevice testDevice) : base(testDevice) public override string Issue => "[Android] BoxView Is InputTransparent Even When Set to False"; - // [FailsOnAndroidWhenRunningOnXamarinUITest] - // [FailsOnIOSWhenRunningOnXamarinUITest] - // [Test] - // [Category(UITestCategories.InputTransparent)] - // public void Bugzilla39331Test() - // { - // App.WaitForElement("btnLogin"); - // App.Tap("btnLogin"); + [Test] + [Category(UITestCategories.InputTransparent)] + public void Bugzilla39331Test() + { + App.WaitForElement("btnLogin"); + App.Tap("btnLogin"); - // App.WaitForTextToBePresentInElement("btnLogin", "Blocked?"); + App.WaitForElement("Blocked?"); - // App.Tap("btnLogin"); + App.Tap("btnLogin"); - // Assert.That(App.FindElement("btnLogin").GetText()? - // .Equals("Guess Not", StringComparison.OrdinalIgnoreCase), - // Is.False); - // } + App.WaitForElement("Guess Not"); + } } From 47da12ee1d33bda7f12b976a4befa98c7aa421fd Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:55:31 +0530 Subject: [PATCH 04/10] Updated the migrated code changes --- .../Issues/Bugzilla/Bugzilla38731.cs | 1 + .../Issues/Bugzilla/Bugzilla40005.cs | 182 ++++++++---------- .../Issues/Bugzilla/Bugzilla40173.cs | 5 +- .../Issues/Bugzilla/Bugzilla52419.cs | 1 + .../Tests/Issues/Bugzilla/Bugzilla32040.cs | 2 +- .../Tests/Issues/Bugzilla/Bugzilla38731.cs | 39 +++- .../Tests/Issues/Bugzilla/Bugzilla39331.cs | 6 +- .../Tests/Issues/Bugzilla/Bugzilla40005.cs | 5 +- .../Tests/Issues/Bugzilla/Bugzilla40173.cs | 14 +- .../Tests/Issues/Bugzilla/Bugzilla45926.cs | 31 ++- .../Tests/Issues/Bugzilla/Bugzilla52419.cs | 51 +++-- .../Tests/Issues/Issue10222.cs | 6 +- .../src/UITest.Appium/HelperExtensions.cs | 43 +++-- 13 files changed, 220 insertions(+), 166 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs index 9aaf6b5a0c84..b71d73af2002 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla38731.cs @@ -95,6 +95,7 @@ public PageFour() { var label = new Label(); label.Text = "Last page... Tap back very quick"; + label.AutomationId = "FinalPage"; label.HorizontalTextAlignment = TextAlignment.Center; var content = new StackLayout(); diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs index 8174c3f74ec9..d1be943d7dfb 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40005.cs @@ -6,144 +6,122 @@ namespace Maui.Controls.Sample.Issues [Issue(IssueTracker.Bugzilla, 40005, "Navigation Bar back button does not show when using InsertPageBefore")] public class Bugzilla40005 : NavigationPage { - public Bugzilla40005() : base(new MainPage()) + public const string GoToPage2 = "Go to Page 2"; + public const string PageOneLabel = "Page 1"; + public const string PageTwoLabel = "Page 2"; + public const string InsertedPageLabel = "Inserted page"; + public const string TestInstructions = "Click " + GoToPage2 + " and you should still see a back bar button"; + + public Bugzilla40005() : base(new Page1()) { + } + - public class MainPage : ContentPage + public class Page1 : ContentPage { - public const string GoToPage1 = "Go to Page 1"; - public const string GoToPage2 = "Go to Page 2"; - public const string PageOneLabel = "Page 1"; - public const string PageTwoLabel = "Page 2"; - public const string InsertedPageLabel = "Inserted page"; - public const string TestInstructions = "Click " + GoToPage2 + " and you should still see a back bar button"; + + bool pageInserted; - public MainPage() + public Page1() { + var btn = new Button() + { + AutomationId = GoToPage2, + Text = GoToPage2 + }; + btn.Clicked += async (sender, e) => + { + await Navigation.PushAsync(new Page2()); + }; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = - { - new Button - { - AutomationId = GoToPage1, - Text = GoToPage1, - Command = new Command(() => - { - Navigation.PushAsync(new Page1()); - }) - } - } - }; - } - - public class Page1 : ContentPage - { - bool pageInserted; - - public Page1() { - var btn = new Button() + new Label { - AutomationId = GoToPage2, - Text = GoToPage2 - }; - btn.Clicked += async (sender, e) => + AutomationId = PageOneLabel, + HorizontalTextAlignment = TextAlignment.Center, + Text = PageOneLabel + }, + btn, + new Label { - await Navigation.PushAsync(new Page2()); - }; - - Content = new StackLayout - { - VerticalOptions = LayoutOptions.Center, - Children = - { - new Label - { - AutomationId = PageOneLabel, - HorizontalTextAlignment = TextAlignment.Center, - Text = PageOneLabel - }, - btn, - new Label - { - AutomationId = TestInstructions, - HorizontalTextAlignment = TextAlignment.Center, - Text = TestInstructions - } + AutomationId = TestInstructions, + HorizontalTextAlignment = TextAlignment.Center, + Text = TestInstructions } - }; } + }; + } - protected override void OnAppearing() + protected override void OnAppearing() + { + base.OnAppearing(); + if (!pageInserted) { - base.OnAppearing(); - if (!pageInserted) - { - Navigation.InsertPageBefore(new InsertedPage(), this); - pageInserted = true; - } + Navigation.InsertPageBefore(new InsertedPage(), this); + pageInserted = true; } + } - protected override bool OnBackButtonPressed() - { - Debug.WriteLine($"Hardware BackButton Pressed on {PageOneLabel}"); - return base.OnBackButtonPressed(); - } + protected override bool OnBackButtonPressed() + { + Debug.WriteLine($"Hardware BackButton Pressed on {PageOneLabel}"); + return base.OnBackButtonPressed(); } + } - public class InsertedPage : ContentPage + public class InsertedPage : ContentPage + { + public InsertedPage() { - public InsertedPage() + Content = new StackLayout { - Content = new StackLayout - { - VerticalOptions = LayoutOptions.Center, - Children = + VerticalOptions = LayoutOptions.Center, + Children = + { + new Label { - new Label - { - HorizontalTextAlignment = TextAlignment.Center, - Text = InsertedPageLabel - } + HorizontalTextAlignment = TextAlignment.Center, + Text = InsertedPageLabel } - }; } + }; + } - protected override bool OnBackButtonPressed() - { - Debug.WriteLine($"Hardware BackButton Pressed on {InsertedPageLabel}"); - return base.OnBackButtonPressed(); - } + protected override bool OnBackButtonPressed() + { + Debug.WriteLine($"Hardware BackButton Pressed on {InsertedPageLabel}"); + return base.OnBackButtonPressed(); } + } - public class Page2 : ContentPage + public class Page2 : ContentPage + { + public Page2() { - public Page2() + Content = new StackLayout { - Content = new StackLayout - { - VerticalOptions = LayoutOptions.Center, - Children = + VerticalOptions = LayoutOptions.Center, + Children = + { + new Label { - new Label - { - AutomationId = PageTwoLabel, - HorizontalTextAlignment = TextAlignment.Center, - Text = PageTwoLabel - } + AutomationId = PageTwoLabel, + HorizontalTextAlignment = TextAlignment.Center, + Text = PageTwoLabel } - }; } + }; + } - protected override bool OnBackButtonPressed() - { - Debug.WriteLine($"Hardware BackButton Pressed on {PageTwoLabel}"); - return base.OnBackButtonPressed(); - } + protected override bool OnBackButtonPressed() + { + Debug.WriteLine($"Hardware BackButton Pressed on {PageTwoLabel}"); + return base.OnBackButtonPressed(); } } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs index b224d33aa1a4..fee499370f7d 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs @@ -18,7 +18,7 @@ public class Bugzilla40173 : TestContentPage protected override void Init() { - var outputLabel = new Label() { AutomationId = "outputlabel" }; + var outputLabel = new Label() { Text="Default", AutomationId = "outputlabel" }; var testButton = new Button { Text = "Can't Touch This", @@ -30,7 +30,8 @@ protected override void Init() var boxView = new BoxView { AutomationId = "nontransparentBoxView", - Color = Colors.Pink.MultiplyAlpha(0.5f) + Color = Colors.Pink.MultiplyAlpha(0.5f), + InputTransparent = false }; // Bump up the elevation on Android so the Button is covered (FastRenderers) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla52419.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla52419.cs index f5312e20d51d..659ed3926344 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla52419.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla52419.cs @@ -44,6 +44,7 @@ public Bugzilla52419Page1() new Button { Text = "Push new page", + AutomationId = "PushNewPage", Command = new Command(() => Navigation.PushAsync(new Bugzilla52419Page1())) } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs index 8155889ff13f..10124d28722f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs @@ -22,6 +22,6 @@ public void TappedWorksForEntryAndSwithCellTest() App.WaitForElement("Tapped"); App.Tap("Click Here"); - Assert.That(App.WaitForElement("yaddayadda").GetText(), Is.EqualTo("Tapped")); + App.WaitForTextToBePresentInElement("yaddayadda", "Tapped"); } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs index d261dc144972..5828865c67fe 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs @@ -6,6 +6,16 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Bugzilla38731 : _IssuesUITest { + +#if ANDROID + const string PageThree = ""; + const string PageTwo = ""; + const string PageOne = ""; +#else + const string PageThree = "Page three"; + const string PageTwo = "Page two"; + const string PageOne = "Page one"; +#endif public Bugzilla38731(TestDevice testDevice) : base(testDevice) { } @@ -24,14 +34,25 @@ public void Bugzilla38731Test () App.WaitForElement("btn3"); App.Tap("btn3"); -#if ANDROID && WINDOWS - App.TapBackArrow(); - App.TapBackArrow(); - App.TapBackArrow(); -#else - App.Back(); - App.Back(); - App.Back(); + +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("FinalPage")); +#endif + App.TapBackArrow(PageThree); + +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("btn3")); +#endif + App.WaitForElement("btn3"); + App.TapBackArrow(PageTwo); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("btn2")); +#endif + App.WaitForElement("btn2"); + App.TapBackArrow(PageOne); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("btn1")); #endif + App.WaitForElement("btn1"); } -} \ No newline at end of file +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs index aa96c312aca0..3d25583a8a72 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS && TEST_FAILS_ON_WINDOWS //Issue reproduced and logged: https://github.com/dotnet/maui/issues/26019. +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -23,6 +24,7 @@ public void Bugzilla39331Test() App.Tap("btnLogin"); - App.WaitForElement("Guess Not"); + Assert.That(App.FindElement("btnLogin").GetText()?.Equals("Guess Not", StringComparison.OrdinalIgnoreCase), Is.False); } } +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs index 5160f8e8141b..b22b068e77b2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40005.cs @@ -6,7 +6,6 @@ namespace Microsoft.Maui.TestCases.Tests.Issues { public class Bugzilla40005 : _IssuesUITest { - public const string GoToPage1 = "Go to Page 1"; public const string GoToPage2 = "Go to Page 2"; public const string PageOneLabel = "Page 1"; public const string PageTwoLabel = "Page 2"; @@ -21,13 +20,13 @@ public Bugzilla40005(TestDevice testDevice) : base(testDevice) [Category(UITestCategories.Navigation)] public void Bugzilla40005Test() { - App.WaitForElement(GoToPage1); - App.Tap(GoToPage1); App.WaitForElement(PageOneLabel); App.Tap(GoToPage2); App.WaitForElement(PageTwoLabel); App.TapBackArrow(); App.WaitForElement(PageOneLabel); + App.TapBackArrow(); + App.WaitForElement("Inserted page"); } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs index 5454b8c1a63f..46624adea7f4 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_ANDROID //Issue reproduced on android and logged the issue: +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -19,16 +20,15 @@ public void ButtonBlocked() App.WaitForElement("CantTouchButtonId"); App.Tap("CantTouchButtonId"); - Assert.That(App.FindElement("outputlabel").GetText()? - .Equals("Failed", StringComparison.OrdinalIgnoreCase), - Is.False); + Assert.That(App.WaitForElement("outputlabel")?.GetText(), Is.EqualTo(("Default"))); App.Tap("CanTouchButtonId"); - App.WaitForElement("ButtonTapped"); + Assert.That(App.WaitForElement("outputlabel")?.GetText(), Is.EqualTo(("ButtonTapped"))); App.WaitForElement("Foo"); App.Tap("Foo"); - App.WaitForElement("ItemTapped"); + Assert.That(App.WaitForElement("outputlabel")?.GetText(), Is.EqualTo(("ItemTapped"))); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs index 5a6b0f94e9d5..6439eac629e2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs @@ -1,6 +1,4 @@ -#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST -//TapBackArrow doesn't work on iOS and Mac. -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -8,6 +6,14 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Bugzilla45926 : _IssuesUITest { +#if ANDROID + const string BackButtonIdentifier1 = ""; + const string BackButtonIdentifier2 = ""; +#else + const string BackButtonIdentifier1 = "Back"; + const string BackButtonIdentifier2 = "Test"; +#endif + public Bugzilla45926(TestDevice testDevice) : base(testDevice) { } @@ -21,10 +27,22 @@ public void Issue45926Test() App.WaitForElement("New Page"); App.Tap("New Page"); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("Second Page #1")); +#else App.WaitForElement("Second Page #1"); - App.TapBackArrow(); +#endif +#if MACCATALYST || IOS + App.WaitForElement("Back"); +#endif + App.TapBackArrow(BackButtonIdentifier1); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById("Intermediate Page")); +#else App.WaitForElement("Intermediate Page"); - App.TapBackArrow(); +#endif + App.TapBackArrow(BackButtonIdentifier2); + App.WaitForElement("Do GC"); App.Tap("Do GC"); App.Tap("Do GC"); App.Tap("Send Message"); @@ -33,5 +51,4 @@ public void Issue45926Test() App.WaitForElement("Instances: 0"); App.WaitForElement("Messages: 0"); } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs index f3953cedbfea..ada36aaa977f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs @@ -1,4 +1,4 @@ -#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS +//#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS //TapBackArrow doesn't work on iOS and Mac. On the Android platform, tapping on Page 2 doesn't work. using NUnit.Framework; using UITest.Appium; @@ -8,6 +8,18 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Bugzilla52419 : _IssuesUITest { +#if ANDROID + const string TabPage1 = "TAB PAGE 1"; + const string TabPage2 = "TAB PAGE 2"; + const string BackButtonIdentifier = ""; +#else + const string TabPage1 = "Tab Page 1"; + const string TabPage2 = "Tab Page 2"; + const string BackButtonIdentifier = "Tab Page 1"; +#endif + const string PushNewPage = "PushNewPage"; + const string AppearanceLabel = "AppearanceLabel"; + public Bugzilla52419(TestDevice testDevice) : base(testDevice) { } @@ -18,19 +30,28 @@ public Bugzilla52419(TestDevice testDevice) : base(testDevice) [Category(UITestCategories.TabbedPage)] public void Bugzilla52419Test() { - App.WaitForElement("Push new page"); - App.Tap("Push new page"); - App.WaitForElement("Push new page"); - App.Tap("Push new page"); - App.WaitForElement("Push new page"); - App.Tap("Push new page"); - App.Tap("Tab Page 2"); - App.Tap("Tab Page 1"); - App.Tap("Tab Page 2"); - App.Tap("Tab Page 1"); - App.TapBackArrow(); - App.WaitForElement("AppearanceLabel"); - Assert.That(App.WaitForElement("AppearanceLabel").GetText(), Is.EqualTo("Times Appeared: 2")); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById(PushNewPage)); +#endif + App.WaitForElement(PushNewPage); + App.Tap(PushNewPage); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById(PushNewPage)); +#endif + App.WaitForElement(PushNewPage); + App.Tap(PushNewPage); +#if MACCATALYST + App.WaitForElement(AppiumQuery.ById(PushNewPage)); +#endif + App.WaitForElement(PushNewPage); + App.Tap(PushNewPage); + App.Tap(TabPage2); + App.Tap(TabPage1); + App.Tap(TabPage2); + App.Tap(TabPage1); + App.WaitForElement(PushNewPage); + App.TapBackArrow(BackButtonIdentifier); + App.WaitForElement(AppearanceLabel); + Assert.That(App.WaitForElement(AppearanceLabel).GetText(), Is.EqualTo("Times Appeared: 2")); } } -#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs index 93e60c53b3d4..88baf91b3d69 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs @@ -1,5 +1,4 @@ -#if TEST_FAILS_ON_ANDROID -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -24,5 +23,4 @@ public void Issue10222Test() } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index f900fb8b38c5..1b574cd82bcb 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1660,20 +1660,35 @@ public static IList GetPerformanceData(this IApp app, string performance /// /// 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")); + /// The IApp instance representing the main gateway to interact with the application. + /// Optional. The custom identifier for the back button. If not provided, default platform-specific identifiers will be used. + public static void TapBackArrow(this IApp app, string customBackButtonIdentifier = "") + { + switch (app) + { + case AppiumAndroidApp _: + app.Tap(AppiumQuery.ByXPath(string.IsNullOrEmpty(customBackButtonIdentifier) + ? "//android.widget.ImageButton[@content-desc='Navigate up']" + : $"//android.widget.ImageButton[@content-desc='{customBackButtonIdentifier}']")); + break; + + case AppiumIOSApp _: + case AppiumCatalystApp _: + if (string.IsNullOrEmpty(customBackButtonIdentifier)) + { + app.Tap(AppiumQuery.ByAccessibilityId("Back")); + } + else + { + app.Tap(app is AppiumIOSApp + ? AppiumQuery.ByXPath($"//XCUIElementTypeButton[@name='{customBackButtonIdentifier}']") + : AppiumQuery.ByName(customBackButtonIdentifier)); + } + break; + + case AppiumWindowsApp _: + app.Tap(AppiumQuery.ByAccessibilityId("NavigationViewBackButton")); + break; } } From 7196c93b84122b574f0f9a91acfa0deb1e9112a9 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 21 Nov 2024 19:03:29 +0530 Subject: [PATCH 05/10] Update Bugzilla52419 --- .../Tests/Issues/Bugzilla/Bugzilla52419.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs index ada36aaa977f..087eadf2b920 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs @@ -1,6 +1,4 @@ -//#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS -//TapBackArrow doesn't work on iOS and Mac. On the Android platform, tapping on Page 2 doesn't work. -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; From c044295c3a66b7b867cbfd01479ec8365eba7246 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 21 Nov 2024 19:27:35 +0530 Subject: [PATCH 06/10] Updated the issue link --- .../Tests/Issues/Bugzilla/Bugzilla40173.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs index 46624adea7f4..3bc49b23194a 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla40173.cs @@ -1,4 +1,4 @@ -#if TEST_FAILS_ON_ANDROID //Issue reproduced on android and logged the issue: +#if TEST_FAILS_ON_ANDROID //Issue reproduced on android and logged the issue: https://github.com/dotnet/maui/issues/26026 using NUnit.Framework; using UITest.Appium; using UITest.Core; From 29393b786616f1630defb64397d8b6977e98d475 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:16:37 +0530 Subject: [PATCH 07/10] Updated the review changes --- .../Issues/Bugzilla/Bugzilla40173.cs | 3 +- .../Tests/Issues/Bugzilla/Bugzilla32040.cs | 3 ++ .../Tests/Issues/Bugzilla/Bugzilla38731.cs | 36 ++++++++----------- .../Tests/Issues/Bugzilla/Bugzilla45926.cs | 17 ++++----- .../Tests/Issues/Bugzilla/Bugzilla52419.cs | 16 +++------ .../src/UITest.Appium/HelperExtensions.cs | 15 ++++++++ 6 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs index fee499370f7d..cd358b9ca174 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla40173.cs @@ -30,8 +30,7 @@ protected override void Init() var boxView = new BoxView { AutomationId = "nontransparentBoxView", - Color = Colors.Pink.MultiplyAlpha(0.5f), - InputTransparent = false + Color = Colors.Pink.MultiplyAlpha(0.5f) }; // Bump up the elevation on Android so the Button is covered (FastRenderers) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs index 10124d28722f..86d2ddd7d17f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32040.cs @@ -22,6 +22,9 @@ public void TappedWorksForEntryAndSwithCellTest() App.WaitForElement("Tapped"); App.Tap("Click Here"); + + //FindElements consistently returns a zero count, despite the "Tapped" text being visible in the UI. + //Assert.That(App.FindElements("Tapped").Count, Is.GreaterThanOrEqualTo(2)); App.WaitForTextToBePresentInElement("yaddayadda", "Tapped"); } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs index 5828865c67fe..38fe6dc2ce1e 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla38731.cs @@ -16,6 +16,10 @@ public class Bugzilla38731 : _IssuesUITest const string PageTwo = "Page two"; const string PageOne = "Page one"; #endif + const string btn1 = "btn1"; + const string btn2 = "btn2"; + const string btn3 = "btn3"; + public Bugzilla38731(TestDevice testDevice) : base(testDevice) { } @@ -26,33 +30,21 @@ public Bugzilla38731(TestDevice testDevice) : base(testDevice) [Category(UITestCategories.Navigation)] public void Bugzilla38731Test () { - App.WaitForElement("btn1"); - App.Tap("btn1"); + App.WaitForElement(btn1); + App.Tap(btn1); - App.WaitForElement("btn2"); - App.Tap("btn2"); + App.WaitForElement(btn2); + App.Tap(btn2); - App.WaitForElement("btn3"); - App.Tap("btn3"); + App.WaitForElement(btn3); + App.Tap(btn3); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("FinalPage")); -#endif + App.WaitForElementTillPageNavigationSettled("FinalPage"); App.TapBackArrow(PageThree); - -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("btn3")); -#endif - App.WaitForElement("btn3"); + App.WaitForElementTillPageNavigationSettled(btn3); App.TapBackArrow(PageTwo); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("btn2")); -#endif - App.WaitForElement("btn2"); + App.WaitForElementTillPageNavigationSettled(btn2); App.TapBackArrow(PageOne); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("btn1")); -#endif - App.WaitForElement("btn1"); + App.WaitForElementTillPageNavigationSettled(btn1); } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs index 6439eac629e2..f1bf075e9625 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45926.cs @@ -27,20 +27,15 @@ public void Issue45926Test() App.WaitForElement("New Page"); App.Tap("New Page"); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("Second Page #1")); -#else - App.WaitForElement("Second Page #1"); -#endif -#if MACCATALYST || IOS + App.WaitForElementTillPageNavigationSettled("Second Page #1"); + + //Getting nullreference exception on iOS while tapping back button. so using waitforElement for back button element. +#if IOS App.WaitForElement("Back"); #endif + App.TapBackArrow(BackButtonIdentifier1); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById("Intermediate Page")); -#else - App.WaitForElement("Intermediate Page"); -#endif + App.WaitForElementTillPageNavigationSettled("Intermediate Page"); App.TapBackArrow(BackButtonIdentifier2); App.WaitForElement("Do GC"); App.Tap("Do GC"); diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs index 087eadf2b920..e1fc8e0c32ba 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla52419.cs @@ -28,21 +28,13 @@ public Bugzilla52419(TestDevice testDevice) : base(testDevice) [Category(UITestCategories.TabbedPage)] public void Bugzilla52419Test() { -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById(PushNewPage)); -#endif - App.WaitForElement(PushNewPage); + App.WaitForElementTillPageNavigationSettled(PushNewPage); App.Tap(PushNewPage); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById(PushNewPage)); -#endif - App.WaitForElement(PushNewPage); + App.WaitForElementTillPageNavigationSettled(PushNewPage); App.Tap(PushNewPage); -#if MACCATALYST - App.WaitForElement(AppiumQuery.ById(PushNewPage)); -#endif - App.WaitForElement(PushNewPage); + App.WaitForElementTillPageNavigationSettled(PushNewPage); App.Tap(PushNewPage); + App.WaitForElementTillPageNavigationSettled(TabPage2); App.Tap(TabPage2); App.Tap(TabPage1); App.Tap(TabPage2); diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index 1b574cd82bcb..a059e1958bce 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1692,6 +1692,21 @@ public static void TapBackArrow(this IApp app, string customBackButtonIdentifier } } + /// + /// Waits for an element to be ready until page navigation has settled, with additional waiting for MacCatalyst. + /// This method helps prevent null reference exceptions during page transitions, especially in MacCatalyst. + /// + /// The IApp instance. + /// The id of the element to wait for. + /// Optional timeout for the wait operation. Default is null, which uses the default timeout. + public static void WaitForElementTillPageNavigationSettled(this IApp app, string elementId, TimeSpan? timeout = null) + { + if(app is AppiumCatalystApp) + app.WaitForElement(AppiumQuery.ById(elementId), timeout: timeout); + + app.WaitForElement(elementId, timeout: timeout); + } + static IUIElement Wait(Func query, Func satisfactory, string? timeoutMessage = null, From d9cac6291cd7f5c6e86872d58b6c57e3c686e9ac Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Sat, 23 Nov 2024 22:53:16 +0530 Subject: [PATCH 08/10] Addressed the review changes --- .../Tests/Issues/Bugzilla/Bugzilla39331.cs | 2 +- .../src/UITest.Appium/HelperExtensions.cs | 108 +++++++++++++----- 2 files changed, 78 insertions(+), 32 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs index 3d25583a8a72..ea3d8fc48340 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla39331.cs @@ -1,4 +1,4 @@ -#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS && TEST_FAILS_ON_WINDOWS //Issue reproduced and logged: https://github.com/dotnet/maui/issues/26019. +#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS && TEST_FAILS_ON_WINDOWS //Issue reproduced and logged: https://github.com/dotnet/maui/issues/26026. using NUnit.Framework; using UITest.Appium; using UITest.Core; diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index a059e1958bce..17a9575317c1 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1658,38 +1658,70 @@ public static IList GetPerformanceData(this IApp app, string performance } /// - /// Navigates back in the application by simulating a tap on the platform-specific back navigation button. + /// Navigates back in the application using default platform-specific identifiers. /// /// The IApp instance representing the main gateway to interact with the application. - /// Optional. The custom identifier for the back button. If not provided, default platform-specific identifiers will be used. - public static void TapBackArrow(this IApp app, string customBackButtonIdentifier = "") - { - switch (app) - { - case AppiumAndroidApp _: - app.Tap(AppiumQuery.ByXPath(string.IsNullOrEmpty(customBackButtonIdentifier) - ? "//android.widget.ImageButton[@content-desc='Navigate up']" - : $"//android.widget.ImageButton[@content-desc='{customBackButtonIdentifier}']")); - break; - - case AppiumIOSApp _: - case AppiumCatalystApp _: - if (string.IsNullOrEmpty(customBackButtonIdentifier)) - { - app.Tap(AppiumQuery.ByAccessibilityId("Back")); - } - else - { - app.Tap(app is AppiumIOSApp - ? AppiumQuery.ByXPath($"//XCUIElementTypeButton[@name='{customBackButtonIdentifier}']") - : AppiumQuery.ByName(customBackButtonIdentifier)); - } - break; - - case AppiumWindowsApp _: - app.Tap(AppiumQuery.ByAccessibilityId("NavigationViewBackButton")); - break; - } + public static void TapBackArrow(this IApp app) + { + TapBackArrow(app, GetDefaultBackArrowQuery(app)); + } + + /// + /// Navigates back in the application using a custom identifier string. + /// + /// The IApp instance representing the main gateway to interact with the application. + /// The custom identifier string for the back button. + public static void TapBackArrow(this IApp app, string customBackButtonIdentifier) + { + TapBackArrow(app, GetCustomBackArrowQuery(app, customBackButtonIdentifier)); + } + + /// + /// Navigates back in the application using a custom IQuery. + /// + /// The IApp instance representing the main gateway to interact with the application. + /// The custom IQuery for the back button. + public static void TapBackArrow(this IApp app, IQuery query) + { + app.Tap(query); + } + + /// + /// Gets the default query for the back arrow button based on the app type. + /// + /// The IApp instance representing the application. + /// An IQuery for the default back arrow button. + /// Thrown when an unsupported app type is provided. + static IQuery GetDefaultBackArrowQuery(IApp app) + { + return app switch + { + AppiumAndroidApp _ => AppiumQuery.ByXPath("//android.widget.ImageButton[@content-desc='Navigate up']"), + AppiumIOSApp _ => AppiumQuery.ByAccessibilityId("Back"), + AppiumCatalystApp _ => AppiumQuery.ByAccessibilityId("Back"), + AppiumWindowsApp _ => AppiumQuery.ByAccessibilityId("NavigationViewBackButton"), + _ => throw new ArgumentException("Unsupported app type", nameof(app)) + }; + } + + /// + /// Gets a custom query for the back arrow button based on the app type and a custom identifier. + /// Note that for Windows apps, the back button is not customizable, so the default identifier is used. + /// + /// The IApp instance representing the application. + /// The custom identifier for the back button. + /// An IQuery for the custom back arrow button. + /// Thrown when an unsupported app type is provided. + static IQuery GetCustomBackArrowQuery(IApp app, string customBackButtonIdentifier) + { + return app switch + { + AppiumAndroidApp _ => AppiumQuery.ByXPath($"//android.widget.ImageButton[@content-desc='{customBackButtonIdentifier}']"), + AppiumIOSApp _ => AppiumQuery.ByXPath($"//XCUIElementTypeButton[@name='{customBackButtonIdentifier}']"), + AppiumCatalystApp _ => AppiumQuery.ByName(customBackButtonIdentifier), + AppiumWindowsApp _ => AppiumQuery.ByAccessibilityId("NavigationViewBackButton"), + _ => throw new ArgumentException("Unsupported app type", nameof(app)) + }; } /// @@ -1703,10 +1735,24 @@ public static void WaitForElementTillPageNavigationSettled(this IApp app, string { if(app is AppiumCatalystApp) app.WaitForElement(AppiumQuery.ById(elementId), timeout: timeout); - + app.WaitForElement(elementId, timeout: timeout); } + /// + /// Waits for an element to be ready until page navigation has settled, with additional waiting for MacCatalyst. + /// This method helps prevent null reference exceptions during page transitions, especially in MacCatalyst. + /// + /// The IApp instance. + /// The query to use for finding the element. + /// Optional timeout for the wait operation. Default is null, which uses the default timeout. + public static void WaitForElementTillPageNavigationSettled(this IApp app, IQuery query, TimeSpan? timeout = null) + { + if(app is AppiumCatalystApp) + app.WaitForElement(query, timeout: timeout); + + app.WaitForElement(query, timeout: timeout); + } static IUIElement Wait(Func query, Func satisfactory, string? timeoutMessage = null, From 6c854e51d4244d7b873593bb0a274d6af7eff187 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:15:53 +0530 Subject: [PATCH 09/10] Update HelperExtensions.cs --- .../src/UITest.Appium/HelperExtensions.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index 1ec92f3fe7c8..0ec7267b1424 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1758,22 +1758,17 @@ public static IDictionary GetSystemBars(this IApp app) } /// - /// Navigates back in the application by simulating a tap on the platform-specific back navigation button. + /// Navigates back in the application by simulating a tap on the platform-specific back navigation button or using a custom identifier. /// /// The IApp instance representing the main gateway to interact with the application. - public static void TapBackArrow(this IApp app) + /// Optional custom identifier string for the back button. If not provided, the default back arrow query will be used. + public static void TapBackArrow(this IApp app, string customBackButtonIdentifier = "") { - TapBackArrow(app, GetDefaultBackArrowQuery(app)); - } + var query = string.IsNullOrEmpty(customBackButtonIdentifier) + ? GetDefaultBackArrowQuery(app) + : GetCustomBackArrowQuery(app, customBackButtonIdentifier); - /// - /// Navigates back in the application using a custom identifier string. - /// - /// The IApp instance representing the main gateway to interact with the application. - /// The custom identifier string for the back button. - public static void TapBackArrow(this IApp app, string customBackButtonIdentifier) - { - TapBackArrow(app, GetCustomBackArrowQuery(app, customBackButtonIdentifier)); + TapBackArrow(app, query); } /// From bc2cb494848176230118346799a3e5934e809a41 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:12:14 +0530 Subject: [PATCH 10/10] Resolved CI failure for the Issue10222Test --- src/Controls/tests/TestCases.HostApp/Issues/Issue10222.cs | 1 + .../tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue10222.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue10222.cs index c448eadde859..1a8f2537acc4 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue10222.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue10222.cs @@ -41,6 +41,7 @@ public CarouselViewTestPage() Margin = new Thickness(0, 100) }; label.SetBinding(Label.TextProperty, new Binding(".")); + label.SetBinding(Label.AutomationIdProperty, new Binding(".")); return label; }) }; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs index 88baf91b3d69..dee30ab706e2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10222.cs @@ -18,7 +18,7 @@ public void Issue10222Test() { App.WaitForElement("goTo"); App.Tap("goTo"); - App.WaitForElement("collectionView"); + App.WaitForElement("items1"); App.WaitForElement("goTo"); }