Skip to content

Commit 026da41

Browse files
committed
fixes
1 parent d2b85d5 commit 026da41

2 files changed

Lines changed: 19 additions & 25 deletions

File tree

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using Maui.Controls.Sample;
2-
using NUnit.Framework;
3-
using OpenQA.Selenium.Appium;
1+
using NUnit.Framework;
2+
using NUnit.Framework.Legacy;
43
using UITest.Appium;
54
using UITest.Core;
65

@@ -18,62 +17,58 @@ protected override void NavigateToGallery()
1817
App.NavigateToGallery("Alerts Gallery");
1918
}
2019

20+
// TODO: UI testing alert code is not yet implemented on Windows.
21+
#if !WINDOWS
2122
[Test]
2223
public void AlertCancel()
2324
{
24-
if (Device == TestDevice.Windows)
25-
Assert.Ignore("UI testing alert code is not yet implemented on Windows.");
26-
2725
var test = Test.Alerts.AlertCancel;
2826

2927
var remote = new EventViewContainerRemote(UITestContext, test);
3028
remote.GoTo(test.ToString());
3129

3230
var textBeforeClick = remote.GetEventLabel().GetText();
33-
Assert.AreEqual($"Event: {test} (none)", textBeforeClick);
31+
ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick);
3432

3533
remote.TapView();
3634

3735
var alert = App.WaitForElement(() => App.GetAlert());
38-
Assert.NotNull(alert);
36+
ClassicAssert.NotNull(alert);
3937

4038
var alertText = alert.GetAlertText();
4139
CollectionAssert.Contains(alertText, "Alert Title Here");
4240
CollectionAssert.Contains(alertText, "Alert Message Here");
4341

4442
var buttons = alert.GetAlertButtons();
4543
CollectionAssert.IsNotEmpty(buttons);
46-
Assert.True(buttons.Count == 1, $"Expected 1 buttonText, found {buttons.Count}.");
44+
ClassicAssert.True(buttons.Count == 1, $"Expected 1 buttonText, found {buttons.Count}.");
4745

4846
var cancel = buttons.First();
49-
Assert.AreEqual("CANCEL", cancel.GetText());
47+
ClassicAssert.AreEqual("CANCEL", cancel.GetText());
5048

5149
cancel.Click();
5250

5351
App.WaitForNoElement(() => App.GetAlert());
5452

5553
var textAfterClick = remote.GetEventLabel().GetText();
56-
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
54+
ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
5755
}
5856

5957
[Test]
6058
[TestCase(Test.Alerts.AlertAcceptCancelClickAccept, "ACCEPT")]
6159
[TestCase(Test.Alerts.AlertAcceptCancelClickCancel, "CANCEL")]
6260
public void AlertAcceptCancel(Test.Alerts test, string buttonText)
6361
{
64-
if (Device == TestDevice.Windows)
65-
Assert.Ignore("UI testing alert code is not yet implemented on Windows.");
66-
6762
var remote = new EventViewContainerRemote(UITestContext, test);
6863
remote.GoTo(test.ToString());
6964

7065
var textBeforeClick = remote.GetEventLabel().GetText();
71-
Assert.AreEqual($"Event: {test} (none)", textBeforeClick);
66+
ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick);
7267

7368
remote.TapView();
7469

7570
var alert = App.WaitForElement(() => App.GetAlert());
76-
Assert.NotNull(alert);
71+
ClassicAssert.NotNull(alert);
7772

7873
var alertText = alert.GetAlertText();
7974
CollectionAssert.Contains(alertText, "Alert Title Here");
@@ -83,7 +78,7 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText)
8378
.Select(b => (Element: b, Text: b.GetText()))
8479
.ToList();
8580
CollectionAssert.IsNotEmpty(buttons);
86-
Assert.True(buttons.Count == 2, $"Expected 2 buttons, found {buttons.Count}.");
81+
ClassicAssert.True(buttons.Count == 2, $"Expected 2 buttons, found {buttons.Count}.");
8782
CollectionAssert.Contains(buttons.Select(b => b.Text), "ACCEPT");
8883
CollectionAssert.Contains(buttons.Select(b => b.Text), "CANCEL");
8984

@@ -93,7 +88,7 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText)
9388
App.WaitForNoElement(() => App.GetAlert());
9489

9590
var textAfterClick = remote.GetEventLabel().GetText();
96-
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
91+
ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
9792
}
9893

9994
[Test]
@@ -102,19 +97,16 @@ public void AlertAcceptCancel(Test.Alerts test, string buttonText)
10297
[TestCase(Test.Alerts.ActionSheetClickDestroy, "DESTROY")]
10398
public void ActionSheetClickItem(Test.Alerts test, string itemText)
10499
{
105-
if (Device == TestDevice.Windows)
106-
Assert.Ignore("UI testing alert code is not yet implemented on Windows.");
107-
108100
var remote = new EventViewContainerRemote(UITestContext, test);
109101
remote.GoTo(test.ToString());
110102

111103
var textBeforeClick = remote.GetEventLabel().GetText();
112-
Assert.AreEqual($"Event: {test} (none)", textBeforeClick);
104+
ClassicAssert.AreEqual($"Event: {test} (none)", textBeforeClick);
113105

114106
remote.TapView();
115107

116108
var alert = App.WaitForElement(() => App.GetAlert());
117-
Assert.NotNull(alert);
109+
ClassicAssert.NotNull(alert);
118110

119111
var alertText = alert.GetAlertText();
120112
CollectionAssert.Contains(alertText, "Action Sheet Title Here");
@@ -123,7 +115,7 @@ public void ActionSheetClickItem(Test.Alerts test, string itemText)
123115
.Select(b => (Element: b, Text: b.GetText()))
124116
.ToList();
125117
CollectionAssert.IsNotEmpty(buttons);
126-
Assert.True(buttons.Count == 5, $"Expected 5 buttons, found {buttons.Count}.");
118+
ClassicAssert.True(buttons.Count == 5, $"Expected 5 buttons, found {buttons.Count}.");
127119
CollectionAssert.Contains(buttons.Select(b => b.Text), "CANCEL");
128120
CollectionAssert.Contains(buttons.Select(b => b.Text), "DESTROY");
129121
CollectionAssert.Contains(buttons.Select(b => b.Text), "ITEM 1");
@@ -136,7 +128,8 @@ public void ActionSheetClickItem(Test.Alerts test, string itemText)
136128
App.WaitForNoElement(() => App.GetAlert());
137129

138130
var textAfterClick = remote.GetEventLabel().GetText();
139-
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
131+
ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
140132
}
133+
#endif
141134
}
142135
}

src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public AppiumCatalystApp(Uri remoteAddress, IConfig config)
1212
{
1313
_commandExecutor.AddCommandGroup(new AppiumCatalystMouseActions(this));
1414
_commandExecutor.AddCommandGroup(new AppiumCatalystTouchActions(this));
15+
_commandExecutor.AddCommandGroup(new AppiumAppleAlertActions(this));
1516
}
1617

1718
public override ApplicationState AppState

0 commit comments

Comments
 (0)