diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/PickerFeatureTests.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/PickerFeatureTests.cs index c3e80d443eda..9de02fc1730a 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/PickerFeatureTests.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/PickerFeatureTests.cs @@ -6,6 +6,7 @@ namespace Microsoft.Maui.TestCases.Tests { public class PickerFeatureTests : _GalleryUITest { + string doneButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; public const string PickerFeatureMatrix = "Picker Feature Matrix"; public override string GalleryPageName => PickerFeatureMatrix; @@ -42,8 +43,8 @@ public void Picker_TapPicker_TakeScreenshot() VerifyPickerScreenshot(); #if IOS - App.WaitForElement("Done"); - App.Tap("Done"); + App.WaitForElement(doneButton); + App.Tap(doneButton); #elif WINDOWS App.Tap("Option 2 - Second option"); #endif diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41424.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41424.cs index 48545bf6aa1d..9382d352c5d9 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41424.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41424.cs @@ -10,7 +10,7 @@ public class Bugzilla41424 : _IssuesUITest #if ANDROID // Action button on TimePicker dialog is vary on different platforms. const string DatePickerActionButton = "Cancel"; #elif IOS - const string DatePickerActionButton = "Done"; + string DatePickerActionButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; #elif WINDOWS // No Action button for Windows DatePicker, so picking any date will close the dialog on windows. const string DatePickerActionButton = "1"; #elif MACCATALYST // Appium cannot locate the dialog elements on a Mac, so tapping outside the dialog closes it. diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla42074.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla42074.cs index d1efe5ca678e..702ee1d541b8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla42074.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla42074.cs @@ -11,7 +11,7 @@ public class Bugzilla42074 : _IssuesUITest #if ANDROID // Action button on TimePicker dialog is vary on different platforms const string TimePickerActionButton = "Cancel"; #elif IOS - const string TimePickerActionButton = "Done"; + string TimePickerActionButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; #elif WINDOWS const string TimePickerActionButton = "Accept"; #endif diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31167.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31167.cs index 688739b8091c..872716b43fbb 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31167.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31167.cs @@ -7,6 +7,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Issue31167 : _IssuesUITest { + string doneButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; public Issue31167(TestDevice testDevice) : base(testDevice) { } @@ -36,9 +37,9 @@ public void DatePickerYearFormat_UserInteraction_MaintainsFourDigitYear() // Simulate user interaction by opening and closing the DatePicker App.Tap("MyDatePicker"); - // On iOS, tap Done to close the picker - App.WaitForElement("Done"); - App.Tap("Done"); + // On iOS, tap Done (or "selected" on iOS 26+) to close the picker + App.WaitForElement(doneButton); + App.Tap(doneButton); // Verify text still shows 4-digit year after interaction var afterInteractionText = App.WaitForElement("MyDatePicker").GetText(); @@ -109,10 +110,10 @@ public void DatePickerYearFormat_iOS_ConsistentAfterMultipleInteractions() { // Open picker App.Tap("MyDatePicker"); - App.WaitForElement("Done"); + App.WaitForElement(doneButton); // Close picker - App.Tap("Done"); + App.Tap(doneButton); // Verify format is still consistent var currentText = App.WaitForElement("MyDatePicker").GetText(); diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs index dbf090497320..965bd5664fb2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs @@ -12,7 +12,7 @@ public Issue31889(TestDevice testDevice) : base(testDevice) { } private const string TestEditorId = "TestEditor"; private const string DarkThemeButtonId = "DarkThemeButton"; private const string LightThemeButtonId = "LightThemeButton"; - private const string DoneButtonId = "Done"; + string DoneButtonId => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; private const string TextColorDarkTheme = "EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme"; private const string TextColorLightTheme = "EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme"; private const string PlaceholderColorDarkTheme = "EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme"; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs index 7e5e6aa69af1..7568cf74de4b 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs @@ -6,6 +6,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Issue32984 : _IssuesUITest { + string doneButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; public Issue32984(TestDevice device) : base(device) { @@ -23,8 +24,8 @@ public void Issue32984PickerShouldResize() App.WaitForElement("Cancel"); App.Tap("Cancel"); #elif IOS || MACCATALYST - App.WaitForElement("Done"); - App.Tap("Done"); + App.WaitForElement(doneButton); + App.Tap(doneButton); #elif WINDOWS App.TapCoordinates(10, 10); #endif diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs index 11e5469f91ff..d9b6d29af14d 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs @@ -6,6 +6,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Issue34848 : _IssuesUITest { + string doneButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; public Issue34848(TestDevice testDevice) : base(testDevice) { } public override string Issue => "DatePicker Opened and Closed events are not raised on MacCatalyst"; @@ -22,8 +23,8 @@ public void DatePickerOpenedAndClosedEventsAreRaised() App.Tap("Issue34848TestDatePicker"); #if IOS - // iOS DatePicker uses a wheel picker, so we can just tap the "Done" button to close it - App.Tap("Done"); + // iOS DatePicker uses a wheel picker, so we can just tap the "Done" button (or "selected" on iOS 26+) to close it + App.Tap(doneButton); #elif WINDOWS // On Windows, we can tap a date to close the DatePicker App.Tap("16"); diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue1614.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue1614.cs index 8b40fb1b21a4..d5bdefa911f8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue1614.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue1614.cs @@ -11,7 +11,7 @@ public class Issue1614 : _IssuesUITest #if ANDROID const string Done = "Cancel"; #else - const string Done = "Done"; + string Done => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; #endif public Issue1614(TestDevice testDevice) : base(testDevice) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue5159.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue5159.cs index 92c00150d56d..5565783548ac 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue5159.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue5159.cs @@ -8,6 +8,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; [Category(UITestCategories.Picker)] public class Issue5159 : _IssuesUITest { + string doneButton => App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; const string DatePickerButton = "DatePickerButton"; const string TimePickerButton = "TimePickerButton"; const string PickerButton = "PickerButton"; @@ -22,7 +23,7 @@ public void InvisibleDatepickerShowsDialogOnFocus() { App.WaitForElement("DatePickerButton"); App.Tap(DatePickerButton); - App.WaitForElement("Done"); + App.WaitForElement(doneButton); App.TapCoordinates(5, 100); } @@ -31,7 +32,7 @@ public void InvisibleTimepickerShowsDialogOnFocus() { App.WaitForElement(TimePickerButton); App.Tap(TimePickerButton); - App.WaitForElement("Done"); + App.WaitForElement(doneButton); App.TapCoordinates(5, 100); } @@ -40,7 +41,7 @@ public void InvisiblePickerShowsDialogOnFocus() { App.WaitForElement(PickerButton); App.Tap(PickerButton); - App.WaitForElement("Done"); + App.WaitForElement(doneButton); } } #endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/KeyboardScrolling.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/KeyboardScrolling.cs index 7f4d38fc8c77..6b886cb94cac 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/KeyboardScrolling.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/KeyboardScrolling.cs @@ -103,7 +103,7 @@ internal static bool CheckIfViewAboveKeyboard(IApp app, string marked, bool isEd internal static void HideKeyboard(IApp app, AppiumDriver? driver, bool isEditor) { if (isEditor) - CloseiOSEditorKeyboard(driver); + CloseiOSEditorKeyboard(app, driver); else app.DismissKeyboard(); } @@ -118,9 +118,10 @@ internal static void HideKeyboard(IApp app, AppiumDriver? driver, bool isEditor) return null; } - internal static void CloseiOSEditorKeyboard(AppiumDriver? driver) + internal static void CloseiOSEditorKeyboard(IApp app, AppiumDriver? driver) { - var keyboardDoneButton = driver?.FindElement(MobileBy.Name("Done")); + var doneButtonName = app is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp) ? "selected" : "Done"; + var keyboardDoneButton = driver?.FindElement(MobileBy.Name(doneButtonName)); keyboardDoneButton?.Click(); } diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index 9bd0aefa2bc6..6bbd5cfae4ec 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -80,8 +80,8 @@ public static void RightClick(this IApp app, string element) /// /// Closes a picker dialog using platform-specific dismiss actions. /// For Android, taps the "Cancel" button. - /// For iOS/MacCatalyst, taps the "Done" button. /// For Windows, either taps coordinates (if provided) or the "Cancel" button. + /// For iOS, taps the "selected" button on iOS 26+, otherwise taps the "Done" button. For MacCatalyst, taps the "Done" button. /// /// Represents the main gateway to interact with an app. /// Optional X coordinate for Windows tap. Default is 0. @@ -92,6 +92,10 @@ public static void ClosePicker(this IApp app, int windowsTapx = 0, int windowsTa { app.Tap("Cancel"); } + else if (app is AppiumIOSApp iosApp && IsIOS26OrHigher(iosApp)) + { + app.Tap("selected"); + } else if (app is AppiumIOSApp || app is AppiumCatalystApp) { app.Tap("Done");