public virtual void TestInit() { // Attempt to go back to the main page in case Alarms & Clock app is started in EditAlarm view try { alarmTabElement = session.FindElementByAccessibilityId("AlarmPivotItem"); } catch { session.Navigate().Back(); Thread.Sleep(TimeSpan.FromSeconds(1)); session.DismissAlarmDialogIfThere(); try { alarmTabElement = session.FindElementByAccessibilityId("AlarmPivotItem"); } catch { session.FindElementByAccessibilityId("Back").Click(); // Press back button if navigating back somehow failed session.DismissAlarmDialogIfThere(); alarmTabElement = session.FindElementByAccessibilityId("AlarmPivotItem"); } } Assert.IsNotNull(alarmTabElement); if (!alarmTabElement.Selected) { alarmTabElement.Click(); } }
public void NavigateBack_ModernApp() { session = Utility.CreateNewSession(CommonTestSettings.AlarmClockAppId); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); // Ensure alarms & clock are in Alarm Pivot view session.Navigate().Back(); session.DismissAlarmDialogIfThere(); try { session.FindElementByAccessibilityId("AlarmButton").Click(); } catch (InvalidOperationException) { session.FindElementByAccessibilityId("AlarmPivotItem").Click(); } // Navigate to New Alarm view session.FindElementByAccessibilityId("AddAlarmButton").Click(); Assert.IsNotNull(session.FindElementByAccessibilityId("EditAlarmHeader")); // Navigate back to the original view session.Navigate().Back(); session.DismissAlarmDialogIfThere(); Assert.IsNotNull(session.FindElementByAccessibilityId("AddAlarmButton")); }
protected static void DismissAddAlarmPage() { try { session.FindElementByAccessibilityId("CancelButton").Click(); // Press cancel button to dismiss any non-main page } catch { session.FindElementByAccessibilityId("Back").Click(); // Press back button if cancel button above somehow failed Thread.Sleep(TimeSpan.FromSeconds(1)); session.DismissAlarmDialogIfThere(); } }