@@ -3,24 +3,24 @@ namespace WindowsAlarmsAndClock.Pages
33 using System ;
44 using System . Collections . ObjectModel ;
55 using System . Linq ;
6-
6+ using Elements ;
7+ using Legerity . Extensions ;
78 using Legerity . Pages ;
89 using Legerity . Windows . Extensions ;
910
1011 using Microsoft . VisualStudio . TestTools . UnitTesting ;
1112
1213 using OpenQA . Selenium ;
1314 using OpenQA . Selenium . Appium ;
15+ using OpenQA . Selenium . Remote ;
1416
1517 /// <summary>
1618 /// Defines the alarm page of the Windows Alarms & Clock application.
1719 /// </summary>
18- public class AlarmPage : BasePage
20+ public class AlarmPage : AppPage
1921 {
2022 private readonly By addAlarmButton ;
2123
22- private readonly By selectAlarmsButton ;
23-
2424 private readonly By alarmList ;
2525
2626 /// <summary>
@@ -29,10 +29,11 @@ public class AlarmPage : BasePage
2929 public AlarmPage ( )
3030 {
3131 this . addAlarmButton = ByExtensions . AutomationId ( "AddAlarmButton" ) ;
32- this . selectAlarmsButton = ByExtensions . AutomationId ( "SelectAlarmsButton" ) ;
3332 this . alarmList = ByExtensions . AutomationId ( "AlarmListView" ) ;
3433 }
3534
35+ public AlarmPopup AlarmPopup => this . WindowsApp . FindElement ( ByExtensions . AutomationId ( "EditFlyout" ) ) ;
36+
3637 /// <summary>
3738 /// Gets a given trait of the page to verify that the page is in view.
3839 /// </summary>
@@ -42,12 +43,12 @@ public AlarmPage()
4243 /// Navigates to adding an alarm.
4344 /// </summary>
4445 /// <returns>
45- /// The <see cref="EditAlarmPage "/>.
46+ /// The <see cref="AlarmPage "/>.
4647 /// </returns>
47- public EditAlarmPage GoToAddAlarm ( )
48+ public AlarmPage GoToAddAlarm ( )
4849 {
4950 this . WindowsApp . FindElement ( this . addAlarmButton ) . Click ( ) ;
50- return new EditAlarmPage ( ) ;
51+ return this ;
5152 }
5253
5354 /// <summary>
@@ -57,12 +58,30 @@ public EditAlarmPage GoToAddAlarm()
5758 /// The name of the alarm to edit.
5859 /// </param>
5960 /// <returns>
60- /// The <see cref="EditAlarmPage "/>.
61+ /// The <see cref="AlarmPage "/>.
6162 /// </returns>
62- public EditAlarmPage GoToEditAlarm ( string alarmName )
63+ public AlarmPage GoToEditAlarm ( string alarmName )
6364 {
6465 this . GetListAlarmElement ( alarmName ) . Click ( ) ;
65- return new EditAlarmPage ( ) ;
66+ return this ;
67+ }
68+
69+ public AlarmPage SetAlarmTime ( TimeSpan time )
70+ {
71+ this . AlarmPopup . SetTime ( time ) ;
72+ return this ;
73+ }
74+
75+ public AlarmPage SetAlarmName ( string name )
76+ {
77+ this . AlarmPopup . SetName ( name ) ;
78+ return this ;
79+ }
80+
81+ public AlarmPage SaveAlarm ( )
82+ {
83+ this . AlarmPopup . SaveAlarm ( ) ;
84+ return this ;
6685 }
6786
6887 /// <summary>
@@ -101,7 +120,7 @@ private AppiumWebElement GetListAlarmElement(string name)
101120 this . WindowsApp . FindElement ( this . alarmList ) . FindElements ( By . ClassName ( "ListViewItem" ) ) ;
102121
103122 return listElements . FirstOrDefault (
104- element => element . GetAttribute ( "Name" ) . Contains ( name , StringComparison . CurrentCulture ) ) ;
123+ element => element . GetName ( ) . Contains ( name , StringComparison . CurrentCulture ) ) ;
105124 }
106125 }
107126}
0 commit comments