Skip to content

Commit db2b2eb

Browse files
authored
test: Fix windowsDriver AlarmClock test (#527)
1 parent d68c313 commit db2b2eb

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

test/integration/Windows/MultiSelectControlTest.cs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace Appium.Net.Integration.Tests.Windows
2626
{
2727
public class MultiSelectControlTest
2828
{
29-
private WindowsDriver _driver;
3029
protected static WindowsDriver AlarmClockSession;
3130
protected static WindowsDriver DesktopSession;
3231

@@ -38,6 +37,7 @@ public void Setup()
3837
appCapabilities.App = "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App";
3938
appCapabilities.PlatformName ="Windows";
4039
appCapabilities.DeviceName = "WindowsPC";
40+
appCapabilities.AddAdditionalAppiumOption("ms:experimental-webdriver", true);
4141

4242
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
4343

@@ -56,14 +56,11 @@ public void Setup()
5656
new WindowsDriver(serverUri, desktopCapabilities);
5757
Assert.IsNotNull(DesktopSession);
5858

59-
// Ensure app is started in the default main page
60-
ReturnToMainPage();
6159
}
6260

6361
[OneTimeTearDown]
6462
public void OneTimeTearDown()
6563
{
66-
ReturnToMainPage();
6764
SwitchToAlarmTab();
6865

6966
// Delete all created alarms
@@ -72,7 +69,10 @@ public void OneTimeTearDown()
7269
{
7370
/////// TODO - Implement for Appium
7471
//// AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates);
75-
AlarmClockSession.FindElement(MobileBy.Name("Delete")).Click();
72+
/// AlarmClockSession.FindElement(MobileBy.AccessibilityId("ContextMenuDelete")).Click();
73+
/// For now Click and delete
74+
alarmEntry.Click();
75+
AlarmClockSession.FindElement(MobileBy.AccessibilityId("DeleteButton")).Click();
7676
}
7777

7878
AlarmClockSession.Dispose();
@@ -90,6 +90,7 @@ public void FullMultiSelectScenario()
9090
// Add an alarm at 1 minute after local time
9191
SwitchToAlarmTab();
9292
AddAlarm(localTimeText);
93+
Thread.Sleep(300);
9394
var alarmEntries = AlarmClockSession.FindElements(MobileBy.Name("Windows Application Driver Test Alarm"));
9495
Assert.IsTrue(alarmEntries.Count > 0);
9596
}
@@ -111,7 +112,7 @@ public string ReadLocalTime()
111112
AlarmClockSession.FindElement(MobileBy.AccessibilityId("ClockButton"));
112113
if (worldClockPivotItem != null)
113114
{
114-
localTimeText = AlarmClockSession.FindElement(MobileBy.AccessibilityId("WorldClockItemGrid")).Text;
115+
localTimeText = AlarmClockSession.FindElement(MobileBy.AccessibilityId("TimeBlock")).GetDomAttribute("Name");
115116
var timeStrings = localTimeText.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
116117

117118
foreach (var timeString in timeStrings)
@@ -141,9 +142,9 @@ public void AddAlarm(string timeText)
141142
var period = alarmTime.ToString("tt", fi);
142143

143144
AlarmClockSession.FindElement(MobileBy.AccessibilityId("AddAlarmButton")).Click();
144-
AlarmClockSession.FindElement(MobileBy.AccessibilityId("AlarmNameTextBox")).Clear();
145-
AlarmClockSession.FindElement(MobileBy.AccessibilityId("AlarmNameTextBox"))
146-
.SendKeys("Windows Application Driver Test Alarm");
145+
var alarmNameBox = AlarmClockSession.FindElement(MobileBy.Name("Alarm name"));
146+
alarmNameBox.Clear();
147+
alarmNameBox.SendKeys("Windows Application Driver Test Alarm");
147148
AppiumElement periodSelector = null;
148149
try
149150
{
@@ -154,11 +155,11 @@ public void AddAlarm(string timeText)
154155
hourString = alarmTime.ToString("HH", fi);
155156
}
156157
periodSelector?.FindElement(MobileBy.Name(period)).Click();
157-
AlarmClockSession.FindElement(MobileBy.AccessibilityId("HourLoopingSelector")).FindElement(MobileBy.Name(hourString)).Click();
158-
AlarmClockSession.FindElement(MobileBy.AccessibilityId("MinuteLoopingSelector")).FindElement(MobileBy.Name(minuteString))
159-
.Click();
158+
AlarmClockSession.FindElement(MobileBy.AccessibilityId("HourPicker")).SendKeys(hourString);
159+
AlarmClockSession.FindElement(MobileBy.AccessibilityId("MinutePicker")).Click();
160+
AlarmClockSession.FindElement(MobileBy.AccessibilityId("MinutePicker")).SendKeys(minuteString);
160161
Thread.Sleep(500);
161-
AlarmClockSession.FindElement(MobileBy.AccessibilityId("AlarmSaveButton")).Click();
162+
AlarmClockSession.FindElement(MobileBy.AccessibilityId("PrimaryButton")).Click();
162163
}
163164
}
164165

@@ -175,22 +176,5 @@ public void DismissNotification()
175176
{
176177
}
177178
}
178-
179-
private static void ReturnToMainPage()
180-
{
181-
// Try to return to main page in case application is started in nested view
182-
try
183-
{
184-
AppiumElement backButton = null;
185-
do
186-
{
187-
backButton = AlarmClockSession.FindElement(MobileBy.AccessibilityId("Back"));
188-
backButton.Click();
189-
} while (backButton != null);
190-
}
191-
catch
192-
{
193-
}
194-
}
195179
}
196180
}

0 commit comments

Comments
 (0)