diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs index 7002f1529a64..dd045c83b2ab 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs @@ -1,6 +1,5 @@ -using Maui.Controls.Sample; -using NUnit.Framework; -using OpenQA.Selenium.Appium; +using NUnit.Framework; +using NUnit.Framework.Legacy; using UITest.Appium; using UITest.Core; @@ -18,24 +17,23 @@ protected override void NavigateToGallery() App.NavigateToGallery("Alerts Gallery"); } +// TODO: UI testing alert code is not yet implemented on Windows. +#if !WINDOWS [Test] public void AlertCancel() { - if (Device == TestDevice.Windows) - Assert.Ignore("UI testing alert code is not yet implemented on Windows."); - var test = Test.Alerts.AlertCancel; var remote = new EventViewContainerRemote(UITestContext, test); remote.GoTo(test.ToString()); var textBeforeClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (none)", textBeforeClick); + ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick); remote.TapView(); var alert = App.WaitForElement(() => App.GetAlert()); - Assert.NotNull(alert); + ClassicAssert.NotNull(alert); var alertText = alert.GetAlertText(); CollectionAssert.Contains(alertText, "Alert Title Here"); @@ -43,17 +41,17 @@ public void AlertCancel() var buttons = alert.GetAlertButtons(); CollectionAssert.IsNotEmpty(buttons); - Assert.True(buttons.Count == 1, $"Expected 1 buttonText, found {buttons.Count}."); + ClassicAssert.True(buttons.Count == 1, $"Expected 1 buttonText, found {buttons.Count}."); var cancel = buttons.First(); - Assert.AreEqual("CANCEL", cancel.GetText()); + ClassicAssert.AreEqual("CANCEL", cancel.GetText()); cancel.Click(); App.WaitForNoElement(() => App.GetAlert()); var textAfterClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); + ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); } [Test] @@ -61,19 +59,16 @@ public void AlertCancel() [TestCase(Test.Alerts.AlertAcceptCancelClickCancel, "CANCEL")] public void AlertAcceptCancel(Test.Alerts test, string buttonText) { - if (Device == TestDevice.Windows) - Assert.Ignore("UI testing alert code is not yet implemented on Windows."); - var remote = new EventViewContainerRemote(UITestContext, test); remote.GoTo(test.ToString()); var textBeforeClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (none)", textBeforeClick); + ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick); remote.TapView(); var alert = App.WaitForElement(() => App.GetAlert()); - Assert.NotNull(alert); + ClassicAssert.NotNull(alert); var alertText = alert.GetAlertText(); CollectionAssert.Contains(alertText, "Alert Title Here"); @@ -83,7 +78,7 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText) .Select(b => (Element: b, Text: b.GetText())) .ToList(); CollectionAssert.IsNotEmpty(buttons); - Assert.True(buttons.Count == 2, $"Expected 2 buttons, found {buttons.Count}."); + ClassicAssert.True(buttons.Count == 2, $"Expected 2 buttons, found {buttons.Count}."); CollectionAssert.Contains(buttons.Select(b => b.Text), "ACCEPT"); CollectionAssert.Contains(buttons.Select(b => b.Text), "CANCEL"); @@ -93,7 +88,7 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText) App.WaitForNoElement(() => App.GetAlert()); var textAfterClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); + ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); } [Test] @@ -102,19 +97,16 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText) [TestCase(Test.Alerts.ActionSheetClickDestroy, "DESTROY")] public void ActionSheetClickItem(Test.Alerts test, string itemText) { - if (Device == TestDevice.Windows) - Assert.Ignore("UI testing alert code is not yet implemented on Windows."); - var remote = new EventViewContainerRemote(UITestContext, test); remote.GoTo(test.ToString()); var textBeforeClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (none)", textBeforeClick); + ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick); remote.TapView(); var alert = App.WaitForElement(() => App.GetAlert()); - Assert.NotNull(alert); + ClassicAssert.NotNull(alert); var alertText = alert.GetAlertText(); CollectionAssert.Contains(alertText, "Action Sheet Title Here"); @@ -123,7 +115,7 @@ public void ActionSheetClickItem(Test.Alerts test, string itemText) .Select(b => (Element: b, Text: b.GetText())) .ToList(); CollectionAssert.IsNotEmpty(buttons); - Assert.True(buttons.Count == 5, $"Expected 5 buttons, found {buttons.Count}."); + ClassicAssert.True(buttons.Count == 5, $"Expected 5 buttons, found {buttons.Count}."); CollectionAssert.Contains(buttons.Select(b => b.Text), "CANCEL"); CollectionAssert.Contains(buttons.Select(b => b.Text), "DESTROY"); CollectionAssert.Contains(buttons.Select(b => b.Text), "ITEM 1"); @@ -136,7 +128,8 @@ public void ActionSheetClickItem(Test.Alerts test, string itemText) App.WaitForNoElement(() => App.GetAlert()); var textAfterClick = remote.GetEventLabel().GetText(); - Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); + ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick); } +#endif } } diff --git a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs index 4abb5bcd7294..bf282cfd06d8 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs @@ -12,6 +12,7 @@ public AppiumCatalystApp(Uri remoteAddress, IConfig config) { _commandExecutor.AddCommandGroup(new AppiumCatalystMouseActions(this)); _commandExecutor.AddCommandGroup(new AppiumCatalystTouchActions(this)); + _commandExecutor.AddCommandGroup(new AppiumAppleAlertActions(this)); } public override ApplicationState AppState