From 192596399ea501895cfb17958757173421e83e6e Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Sat, 23 Nov 2024 07:01:40 +0530 Subject: [PATCH 1/2] Nafeela UI tests3 (#14) * Migrated Flyout related Issues * Revert "Migrated Flyout related Issues" This reverts commit 8fbf985f46c43a1919d177bbd8bb2d59f0a5b693. * Migrate the Flyout Issues into Appium * Modify Issue 6184 and Issue 7856 * Updated the migrated code changes * Addressed the review changes * Added one more tab to ensure the more button visibility on windows * Addressed the review changes * Updated the comments --------- Co-authored-by: NafeelaNazhir --- .../Issues/XFIssue/Issue6784.cs | 12 +- .../Issues/XFIssue/Issue7339.cs | 5 +- .../Issues/XFIssue/Issue7856.cs | 2 +- .../Issues/XFIssue/Issue8145.cs | 38 ++++- .../Tests/Issues/XFIssue/Issue6184.cs | 25 +-- .../Tests/Issues/XFIssue/Issue6784.cs | 74 +++++---- .../Tests/Issues/XFIssue/Issue7339.cs | 26 +-- .../Tests/Issues/XFIssue/Issue7856.cs | 27 ++-- .../Tests/Issues/XFIssue/Issue8145.cs | 26 ++- .../src/UITest.Appium/HelperExtensions.cs | 148 ++++++++++++++---- 10 files changed, 256 insertions(+), 127 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue6784.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue6784.cs index 33f85fa4fa44..665407ae4377 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue6784.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue6784.cs @@ -15,16 +15,22 @@ protected override void Init() AddBottomTab("Tab 1"); AddBottomTab("Tab 2"); - AddBottomTab("Tab 3"); + AddBottomTab("Tab 3"); AddBottomTab("Tab 4").AutomationId = "Tab 4 Content"; - var contentPage5 = AddBottomTab("Tab 5"); + AddBottomTab("Tab 5"); AddBottomTab("Tab 6"); + AddBottomTab("Tab 7"); + AddBottomTab("Tab 8"); + AddBottomTab("Tab 9"); + AddBottomTab("Tab 10"); + var contentPage5 = AddBottomTab("Tab 11"); + AddBottomTab("Tab 12"); shellItem.PropertyChanged += (sender, e) => { if (e.PropertyName == CurrentItemProperty.PropertyName) { - if (((ShellItem)sender).CurrentItem.AutomationId == "Tab 5") + if (((ShellItem)sender).CurrentItem.AutomationId == "Tab 11") { contentPage5.Content = new Label() { diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7339.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7339.cs index 0671128538ca..68791f59694d 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7339.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7339.cs @@ -14,12 +14,13 @@ protected override void Init() { Content = new Label() { - Text = "Navigate between flyout items a few times. If app doesn't crash then test has passed" + Text = "Navigate between flyout items a few times. If app doesn't crash then test has passed", + AutomationId = "InstructionLabel" } } }; CreateContentPage("Item2").Content = - new StackLayout() { new Frame() }; + new StackLayout() { new Frame() { Content = new Label() { Text = "FrameContent", AutomationId ="FrameContent" } } }; } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7856.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7856.cs index 74e2e91608f8..77f9a6659e11 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7856.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7856.cs @@ -1,7 +1,7 @@ namespace Maui.Controls.Sample.Issues; [Issue(IssueTracker.Github, 7856, - "[Bug] Shell BackButtonBehaviour TextOverride breaks back", + "[Bug] Shell BackButtonBehaviour TextOverride breaks back", PlatformAffected.iOS)] public class Issue7856 : TestShell { diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8145.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8145.cs index 0cf7947a8ebf..4e2ca4edfc90 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8145.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue8145.cs @@ -1,6 +1,6 @@ namespace Maui.Controls.Sample.Issues; -[Issue(IssueTracker.Github, 8145, "Shell System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Android.Support.Design.Widget.BottomSheetDialog'.'", PlatformAffected.Android)] +[Issue(IssueTracker.Github, 8145, "Shell System.ObjectDisposedException: Cannot access a disposed object. Object name: Android.Support.Design.Widget.BottomSheetDialog", PlatformAffected.Android)] public class Issue8145 : TestShell { string _titleElement = "Connect"; @@ -51,8 +51,40 @@ protected override void Init() Items = { new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } } - }, - new Tab { + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } +#if WINDOWS || MACCATALYST // Add more tab for desktop platforms to make the more button visible + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } + + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } + },new Tab { + Title = "notme", + Items = { + new ContentPage { Title = "notme", Content = new Label { Text = "Click More, then choose the target. If it does not crash, this test has passed." } } + } +#endif + },new Tab { Title = "target", Items = { new ContentPage { Title = "Target", Content = new Label { Text = "Success" } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6184.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6184.cs index 894c96a19a7f..36509fd7db60 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6184.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6184.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS // Cell disabled is not behaves correctly except iOS. More Information: https://github.com/dotnet/maui/issues/5161 +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -12,13 +13,15 @@ public Issue6184(TestDevice testDevice) : base(testDevice) public override string Issue => "Throws exception when set isEnabled to false in ShellItem index > 5"; - //[Test] - //[Category(UITestCategories.Shell)] - //public void GitHubIssue6184() - //{ - // App.WaitForElement(q => q.Marked("More")); - // App.Tap(q => q.Marked("More")); - // App.Tap(q => q.Marked("Issue 5")); - // App.WaitForElement(q => q.Marked("Issue 5")); - //} -} \ No newline at end of file + [Test] + [Category(UITestCategories.Shell)] + public void GitHubIssue6184() + { + App.WaitForElement("More"); + App.Tap("More"); + App.Tap("Issue 5"); + App.WaitForElement("Issue 5"); + + } +} +#endif diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6784.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6784.cs index 3dd9872604e2..37acb37adb36 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6784.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6784.cs @@ -1,4 +1,6 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_WINDOWS // When using App.Tap to interact with tab items which placed in the more section, the action targets the corner of the tabs, Line No 24 +// which doesn't trigger navigation on Windows. Windows requires tapping directly on the tab title text. +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -13,42 +15,38 @@ public Issue6784(TestDevice testDevice) : base(testDevice) public override string Issue => "ShellItem.CurrentItem is not set when selecting shell section aggregated in more tab"; - //[Test] - //public void CurrentItemIsSetWhenSelectingShellSectionAggregatedInMoreTab() - //{ - // App.WaitForElement(x => x.Class("UITabBarButton").Marked("More")); - // App.Tap(x => x.Class("UITabBarButton").Marked("More")); - - // App.WaitForElement(x => x.Class("UITableViewCell").Text("Tab 5")); - // App.Tap(x => x.Class("UITableViewCell").Text("Tab 5")); - - // App.WaitForElement(x => x.Text("Success")); - //} - - //[Test] - //public void MoreControllerOpensOnFirstClick() - //{ - // App.WaitForElement(x => x.Class("UITabBarButton").Marked("More")); - // App.Tap(x => x.Class("UITabBarButton").Marked("More")); - - // App.WaitForElement(x => x.Class("UITableViewCell").Text("Tab 5")); - // App.Tap(x => x.Class("UITableViewCell").Text("Tab 5")); - - // App.Tap(x => x.Class("UITabBarButton").Marked("Tab 4")); - // App.WaitForElement("Tab 4 Content"); - - // App.Tap(x => x.Class("UITabBarButton").Marked("More")); - // App.WaitForElement(x => x.Class("UITableViewCell").Text("Tab 6")); - //} - - //[Test] - //public void MoreControllerDoesNotShowEditButton() - //{ - // App.WaitForElement(x => x.Class("UITabBarButton").Marked("More")); - // App.Tap(x => x.Class("UITabBarButton").Marked("More")); + [Test] + public void CurrentItemIsSetWhenSelectingShellSectionAggregatedInMoreTab() + { + App.WaitForElement("More"); + App.Tap("More"); + App.WaitForElement("Tab 11"); + App.Tap("Tab 11"); + App.WaitForElementTillPageNavigationSettled("Success"); + } - // App.WaitForElement(x => x.Class("UITableViewCell").Text("Tab 5")); + [Test] + public void OneMoreControllerOpensOnFirstClick() + { + App.WaitForElement("More"); + App.Tap("More"); + App.WaitForElement("Tab 11"); + App.Tap("Tab 11"); + App.WaitForElement("Tab 4"); + App.Tap("Tab 4"); + App.WaitForElement("More"); + App.Tap("More"); + App.WaitForElement("Tab 12"); + App.Tap("Tab 12"); + } - // Assert.AreEqual(App.Query(x => x.Marked("Edit")).Count(), 0); - //} -} \ No newline at end of file + [Test] + public void TwoMoreControllerDoesNotShowEditButton() + { + App.WaitForElement("More"); + App.Tap("More"); + App.WaitForElement("Tab 11"); + Assert.That(App.FindElements("Edit").Count(), Is.EqualTo(0)); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7339.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7339.cs index 782c9a93e80b..ecec0286b9b8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7339.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7339.cs @@ -12,14 +12,20 @@ public Issue7339(TestDevice testDevice) : base(testDevice) public override string Issue => "[iOS] Material frame renderer not being cleared"; - // TODO: TapInFlyout was some helper method in ControlGallery? Do we have that here? - //[Test] - //[Category(UITestCategories.Shell)] - //public void MaterialFrameDisposesCorrectly() - //{ - // TapInFlyout("Item1"); - // TapInFlyout("Item2"); - // TapInFlyout("Item1"); - // TapInFlyout("Item2"); - //} + + [Test] + [Category(UITestCategories.Shell)] + public void MaterialFrameDisposesCorrectly() + { + App.WaitForElement("InstructionLabel"); + App.TapInFlyout("Item1"); + App.WaitForElementTillPageNavigationSettled("InstructionLabel"); + App.TapInFlyout("Item2"); + App.WaitForElementTillPageNavigationSettled("FrameContent"); + App.TapInFlyout("Item1"); + App.WaitForElementTillPageNavigationSettled("InstructionLabel"); + App.TapInFlyout("Item2"); + App.WaitForElementTillPageNavigationSettled("FrameContent"); + + } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7856.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7856.cs index a6e9d74d42f5..ea4d6f1800fc 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7856.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue7856.cs @@ -10,20 +10,17 @@ public Issue7856(TestDevice testDevice) : base(testDevice) { } - public override string Issue => "[Bug] Shell BackButtonBehaviour TextOverride breaks back"; + public override string Issue => "[Bug] Shell BackButtonBehaviour TextOverride breaks back"; - //[Test] - //[Category(UITestCategories.Shell)] - //public void BackButtonBehaviorTest() - //{ - // App.Tap(x => x.Text("Tap to Navigate To the Page With BackButtonBehavior")); - - // App.WaitForElement(x => x.Text("Navigate again")); - - // App.Tap(x => x.Text("Navigate again")); - - // App.WaitForElement(x => x.Text("Test")); - - // App.Tap(x => x.Text("Test")); - //} + [Test] + [Category(UITestCategories.Shell)] + public void BackButtonBehaviorTest() + { + App.WaitForElementTillPageNavigationSettled("Tap to Navigate To the Page With BackButtonBehavior"); + App.Tap("Tap to Navigate To the Page With BackButtonBehavior"); + App.WaitForElement("Navigate again"); + App.Tap("Navigate again"); + App.WaitForElementTillPageNavigationSettled("Hello"); + App.TapBackArrow("Test"); + } } \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8145.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8145.cs index 6a3b6e4dedff..1471a58cfdbe 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8145.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue8145.cs @@ -10,20 +10,16 @@ public Issue8145(TestDevice testDevice) : base(testDevice) { } - public override string Issue => "Shell System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Android.Support.Design.Widget.BottomSheetDialog'.'"; + public override string Issue => "Shell System.ObjectDisposedException: Cannot access a disposed object. Object name: Android.Support.Design.Widget.BottomSheetDialog"; - //[Test] - //[Category(UITestCategories.Shell)] - //#if !(ANDROID || IOS) - // [Ignore("Shell test is only supported on Android and iOS")] - //#endif - // [FailsOnAndroidWhenRunningOnXamarinUITest] - // public void Issue8145ShellToolbarDisposedException() - // { - // App.WaitForElement("More"); - // App.Tap("More"); - // App.WaitForElement("target"); - // App.Tap("target"); - // App.WaitForElement("Success"); - // } + [Test] + [Category(UITestCategories.Shell)] + public void Issue8145ShellToolbarDisposedException() + { + App.WaitForElement("More"); + App.Tap("More"); + App.WaitForElement("target"); + App.Tap("target"); + App.WaitForElement("Success"); + } } \ 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 1b574cd82bcb..bfe81d5635e1 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1658,40 +1658,130 @@ 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)) + }; + } + + /// + /// 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); + } + + /// + /// 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); + } + + /// + /// Flyout icon opens flyout page in the application by simulating a tap on the platform-specific Flyout Icon button. + /// + /// Represents the main gateway to interact with an app. + public static void TapFlyoutIcon(this IApp app) + { + if (app is AppiumAndroidApp) + { + app.Tap(AppiumQuery.ByXPath("//android.widget.ImageButton[@content-desc=\"Open navigation drawer\"]")); + } + else if (app is AppiumIOSApp || app is AppiumCatalystApp || app is AppiumWindowsApp) + { + app.Tap(AppiumQuery.ByAccessibilityId("OK")); } } + /// + /// Taps an item in the flyout menu. + /// + /// The IApp instance representing the application. + /// The text or accessibility identifier of the flyout item to tap. + public static void TapInFlyout(this IApp app, string flyoutitem) + { + app.TapFlyoutIcon(); + app.WaitForElement(flyoutitem); + app.Tap(flyoutitem); + } + static IUIElement Wait(Func query, Func satisfactory, string? timeoutMessage = null, From 44bdcaac20029d375e9f7c3486b89ae0e2f9476c Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Sat, 23 Nov 2024 22:31:17 +0530 Subject: [PATCH 2/2] Update HelperExtensions.cs --- .../src/UITest.Appium/HelperExtensions.cs | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index bfe81d5635e1..fb23f5581b6c 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -1724,35 +1724,35 @@ static IQuery GetCustomBackArrowQuery(IApp app, string customBackButtonIdentifie }; } - /// - /// 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); - } - - /// - /// 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); - } + /// + /// 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); + } + + /// + /// 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); + } /// /// Flyout icon opens flyout page in the application by simulating a tap on the platform-specific Flyout Icon button. @@ -1771,10 +1771,10 @@ public static void TapFlyoutIcon(this IApp app) } /// - /// Taps an item in the flyout menu. - /// - /// The IApp instance representing the application. - /// The text or accessibility identifier of the flyout item to tap. + /// Taps an item in the flyout menu. + /// + /// The IApp instance representing the application. + /// The text or accessibility identifier of the flyout item to tap. public static void TapInFlyout(this IApp app, string flyoutitem) { app.TapFlyoutIcon();