diff --git a/README.md b/README.md index bb3e90d0..c4261ae1 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ Below are the capabilities that can be used to create Windows Application Driver | POST | /session | | GET | /sessions | | DELETE | /session/:sessionId | +| POST | /session/:sessionId/actions (v1.1 RC) | | POST | /session/:sessionId/appium/app/launch | | POST | /session/:sessionId/appium/app/close | | POST | /session/:sessionId/back | diff --git a/Tests/WebDriverAPI/ActionsPen.cs b/Tests/WebDriverAPI/ActionsPen.cs index b1a746d9..1a7f48d9 100644 --- a/Tests/WebDriverAPI/ActionsPen.cs +++ b/Tests/WebDriverAPI/ActionsPen.cs @@ -46,6 +46,36 @@ public static void ClassCleanup() TearDown(); } + [TestMethod] + public void Pen_Click_BarrelButton() + { + // Create a new test alarm + string alarmName = "PenBarrelButtonTest"; + DeletePreviouslyCreatedAlarmEntry(alarmName); + AddAlarmEntry(alarmName); + Thread.Sleep(TimeSpan.FromSeconds(3)); + + var alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]"); + Assert.IsNotNull(alarmEntries); + Assert.AreEqual(1, alarmEntries.Count); + + // Open a the context menu on the alarm entry using long tap (press and hold) action and click delete + PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen); + ActionSequence sequence = new ActionSequence(penDevice, 0); + sequence.AddAction(penDevice.CreatePointerMove(alarmEntries[0], 0, 0, TimeSpan.Zero)); + sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenBarrel)); + sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenBarrel)); + session.PerformActions(new List { sequence }); + + Thread.Sleep(TimeSpan.FromSeconds(1)); + session.FindElementByName("Delete").Click(); + Thread.Sleep(TimeSpan.FromSeconds(1)); + + alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]"); + Assert.IsNotNull(alarmEntries); + Assert.AreEqual(0, alarmEntries.Count); + } + [TestMethod] public void Pen_Click_OriginElement() { @@ -161,7 +191,7 @@ public void Pen_Click_OriginViewport() [TestMethod] public void Pen_DoubleClick() { - WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppName"); + WindowsElement appNameTitle = FindAppTitleBar(); WindowsElement maximizeButton = session.FindElementByAccessibilityId("Maximize"); // Set focus on the application by switching window to itself @@ -203,7 +233,7 @@ public void Pen_DoubleClick() [TestMethod] public void Pen_DragAndDrop() { - WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppName"); + WindowsElement appNameTitle = FindAppTitleBar(); const int offset = 100; // Save application window original position @@ -287,7 +317,6 @@ public void Pen_LongClick() Assert.AreEqual(0, alarmEntries.Count); } - [TestMethod] public void Pen_Scroll_Horizontal() { diff --git a/Tests/WebDriverAPI/ActionsTouch.cs b/Tests/WebDriverAPI/ActionsTouch.cs index ee440f4c..4599effe 100644 --- a/Tests/WebDriverAPI/ActionsTouch.cs +++ b/Tests/WebDriverAPI/ActionsTouch.cs @@ -161,7 +161,7 @@ public void Touch_Click_OriginViewport() [TestMethod] public void Touch_DoubleClick() { - WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppName"); + WindowsElement appNameTitle = FindAppTitleBar(); WindowsElement maximizeButton = session.FindElementByAccessibilityId("Maximize"); // Set focus on the application by switching window to itself @@ -203,7 +203,7 @@ public void Touch_DoubleClick() [TestMethod] public void Touch_DragAndDrop() { - WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppName"); + WindowsElement appNameTitle = FindAppTitleBar(); const int offset = 100; // Save application window original position @@ -287,7 +287,6 @@ public void Touch_LongClick() Assert.AreEqual(0, alarmEntries.Count); } - [TestMethod] public void Touch_Scroll_Horizontal() { diff --git a/Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs b/Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs index e6b1eb84..12ad465d 100644 --- a/Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs +++ b/Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs @@ -70,20 +70,8 @@ public virtual void TestInit() } 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"); - } + DismissAddAlarmPage(); + alarmTabElement = session.FindElementByAccessibilityId("AlarmPivotItem"); } Assert.IsNotNull(alarmTabElement); @@ -146,10 +134,37 @@ protected static WindowsElement GetStaleElement() session.FindElementByAccessibilityId("AddAlarmButton").Click(); Thread.Sleep(TimeSpan.FromSeconds(0.5)); WindowsElement staleElement = session.FindElementByAccessibilityId("AlarmSaveButton"); - session.Navigate().Back(); // Dismiss add alarm page - session.DismissAlarmDialogIfThere(); + DismissAddAlarmPage(); Thread.Sleep(TimeSpan.FromSeconds(2)); return staleElement; } + + 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(); + } + } + + protected static WindowsElement FindAppTitleBar() + { + WindowsElement element; + try + { + element = session.FindElementByAccessibilityId("AppName"); + } + catch (InvalidOperationException) + { + element = session.FindElementByAccessibilityId("TitleBar"); + } + return element; + } } } \ No newline at end of file diff --git a/Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs b/Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs index 5db96f10..0c00e3c5 100644 --- a/Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs +++ b/Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs @@ -116,14 +116,14 @@ protected static RemoteWebElement GetStaleElement() // Navigate to Edge about:flags page session.FindElementByAccessibilityId("addressEditBox").SendKeys(Keys.Alt + 'd' + Keys.Alt + CommonTestSettings.EdgeAboutFlagsURL + Keys.Enter); - Thread.Sleep(TimeSpan.FromSeconds(2)); + Thread.Sleep(TimeSpan.FromSeconds(3)); Assert.AreNotEqual(originalTitle, session.Title); // Save a reference to Reset all flags button on the page and navigate back to home staleElement = session.FindElementByAccessibilityId("ResetAllFlags"); Assert.IsNotNull(staleElement); session.Navigate().Back(); - Thread.Sleep(TimeSpan.FromSeconds(1)); + Thread.Sleep(TimeSpan.FromSeconds(3)); Assert.AreEqual(originalTitle, session.Title); return staleElement; diff --git a/Tests/WebDriverAPI/AppSessionBase/WebDriverApiExtensions.cs b/Tests/WebDriverAPI/AppSessionBase/WebDriverApiExtensions.cs index 5b543140..ae44404f 100644 --- a/Tests/WebDriverAPI/AppSessionBase/WebDriverApiExtensions.cs +++ b/Tests/WebDriverAPI/AppSessionBase/WebDriverApiExtensions.cs @@ -26,11 +26,11 @@ internal static WindowsElement FindCalculatorTitleByAccessibilityId(this Windows WindowsElement element; try { - element = session.FindElementByAccessibilityId("AppNameTitle"); + element = session.FindElementByAccessibilityId("AppName"); } catch (InvalidOperationException) { - element = session.FindElementByAccessibilityId("AppName"); + element = session.FindElementByAccessibilityId("AppNameTitle"); } return element; } diff --git a/Tests/WebDriverAPI/ElementClick.cs b/Tests/WebDriverAPI/ElementClick.cs index 0b31f1be..013977fa 100644 --- a/Tests/WebDriverAPI/ElementClick.cs +++ b/Tests/WebDriverAPI/ElementClick.cs @@ -52,8 +52,7 @@ public void ClickElement() Assert.AreEqual("30", minuteSelector.Text); // Return to main page and click on pivot items to switch between tabs - session.FindElementByAccessibilityId("CancelButton").Click(); - + DismissAddAlarmPage(); WindowsElement worldPivot = session.FindElementByAccessibilityId("WorldClockPivotItem"); WindowsElement alarmPivot = session.FindElementByAccessibilityId("AlarmPivotItem"); diff --git a/Tests/WebDriverAPI/ElementSendKeys.cs b/Tests/WebDriverAPI/ElementSendKeys.cs index a6143700..38d61458 100644 --- a/Tests/WebDriverAPI/ElementSendKeys.cs +++ b/Tests/WebDriverAPI/ElementSendKeys.cs @@ -175,7 +175,7 @@ public void SendKeysToElementError_StaleElement() { try { - session.FindElementByAccessibilityId("CancelButton").Click(); + DismissAddAlarmPage(); Thread.Sleep(TimeSpan.FromSeconds(1)); alarmNameTextBox.SendKeys("keys"); Assert.Fail("Exception should have been thrown"); diff --git a/Tests/WebDriverAPI/Forward.cs b/Tests/WebDriverAPI/Forward.cs index e67e368a..45f2565a 100644 --- a/Tests/WebDriverAPI/Forward.cs +++ b/Tests/WebDriverAPI/Forward.cs @@ -79,10 +79,12 @@ public void NavigateForward_SystemApp() // Navigate back to the original folder session.Navigate().Back(); + Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.AreEqual(originalTitle, session.Title); // Navigate forward to the target folder session.Navigate().Forward(); + Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.AreEqual(newTitle, session.Title); } diff --git a/Tests/WebDriverAPI/TouchScroll.cs b/Tests/WebDriverAPI/TouchScroll.cs index 21606510..96d9119b 100644 --- a/Tests/WebDriverAPI/TouchScroll.cs +++ b/Tests/WebDriverAPI/TouchScroll.cs @@ -107,8 +107,8 @@ public void TouchScrollOnElement_Vertical() Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.IsTrue(minute00.Displayed); - // Navigate back to the original view - session.Navigate().Back(); + // Dismiss add alarm page + DismissAddAlarmPage(); } [TestMethod] diff --git a/Tests/WebDriverAPI/Window.cs b/Tests/WebDriverAPI/Window.cs index a4b1dd9e..f0fb7683 100644 --- a/Tests/WebDriverAPI/Window.cs +++ b/Tests/WebDriverAPI/Window.cs @@ -130,8 +130,11 @@ public void GetWindowHandles_ModernApp() List previouslyOpenedEdgeWindows = new List(windowHandlesBefore); previouslyOpenedEdgeWindows.Remove(session.CurrentWindowHandle); - // Open a new window - session.Keyboard.SendKeys(Keys.Control + "n" + Keys.Control); + // Set focus on itself + session.SwitchTo().Window(session.CurrentWindowHandle); + + // Open a new window in private mode + session.Keyboard.SendKeys(Keys.Control + Keys.Shift + "p" + Keys.Shift + Keys.Control); Thread.Sleep(TimeSpan.FromSeconds(3)); var windowHandlesAfter = session.WindowHandles; Assert.IsNotNull(windowHandlesAfter); @@ -161,8 +164,11 @@ public void SwitchWindows() List previouslyOpenedEdgeWindows = new List(session.WindowHandles); previouslyOpenedEdgeWindows.Remove(session.CurrentWindowHandle); - // Open a new window - session.Keyboard.SendKeys(Keys.Control + "n" + Keys.Control); + // Set focus on itself + session.SwitchTo().Window(session.CurrentWindowHandle); + + // Open a new window in private mode + session.Keyboard.SendKeys(Keys.Control + Keys.Shift + "p" + Keys.Shift + Keys.Control); Thread.Sleep(TimeSpan.FromSeconds(3)); var multipleWindowHandles = session.WindowHandles; Assert.IsTrue(multipleWindowHandles.Count > 1);