Skip to content

Commit 59dd132

Browse files
committed
2 parents 22a8601 + 9373cbd commit 59dd132

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4782
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ obj/
5757

5858
# Visual Studio 2015/2017 cache/options directory
5959
.vs/
60+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Windows Application Driver is integrated with Appium, meaning if you use Appium
214214
2. To create multiple sessions with one Appium server you need Appium 1.6.4 or newer
215215
3. When pointing a test at Appium you need to include `/wd/hub` on the server URI. E.g. `http://127.0.0.1:4723/wd/hub`
216216

217-
For more details visit the Appium documentation: <http://appium.io/slate/en/master/?ruby#windows-application-ui-testing>
217+
For more details visit the Appium documentation: <https://appium.io/docs/en/drivers/windows/>
218218

219219

220220
## Vote on New Features

Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public virtual void TestInit()
7272
{
7373
session.Navigate().Back();
7474
Thread.Sleep(TimeSpan.FromSeconds(1));
75+
session.DismissAlarmDialogIfThere();
7576

7677
try
7778
{
@@ -80,6 +81,7 @@ public virtual void TestInit()
8081
catch
8182
{
8283
session.FindElementByAccessibilityId("Back").Click(); // Press back button if navigating back somehow failed
84+
session.DismissAlarmDialogIfThere();
8385
alarmTabElement = session.FindElementByAccessibilityId("AlarmPivotItem");
8486
}
8587
}
@@ -145,6 +147,7 @@ protected static WindowsElement GetStaleElement()
145147
Thread.Sleep(TimeSpan.FromSeconds(0.5));
146148
WindowsElement staleElement = session.FindElementByAccessibilityId("AlarmSaveButton");
147149
session.Navigate().Back(); // Dismiss add alarm page
150+
session.DismissAlarmDialogIfThere();
148151
Thread.Sleep(TimeSpan.FromSeconds(2));
149152
return staleElement;
150153
}

Tests/WebDriverAPI/AppSessionBase/Utility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static void InitializeOrphanedSession()
113113
// Create new calculator session and close the window to get an orphaned element
114114
CleanupOrphanedSession();
115115
orphanedSession = CreateNewSession(CommonTestSettings.CalculatorAppId);
116-
orphanedElement = orphanedSession.FindElementByAccessibilityId("AppNameTitle");
116+
orphanedElement = orphanedSession.FindCalculatorTitleByAccessibilityId();
117117
orphanedWindowHandle = orphanedSession.CurrentWindowHandle;
118118
orphanedSession.Close();
119119
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//******************************************************************************
2+
//
3+
// Copyright (c) 2017 Microsoft Corporation. All rights reserved.
4+
//
5+
// This code is licensed under the MIT License (MIT).
6+
//
7+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
13+
// THE SOFTWARE.
14+
//
15+
//******************************************************************************
16+
17+
using OpenQA.Selenium.Appium.Windows;
18+
using System;
19+
20+
namespace WebDriverAPI
21+
{
22+
static class WebDriverApiExtensions
23+
{
24+
internal static WindowsElement FindCalculatorTitleByAccessibilityId(this WindowsDriver<WindowsElement> session)
25+
{
26+
WindowsElement element;
27+
try
28+
{
29+
element = session.FindElementByAccessibilityId("AppNameTitle");
30+
}
31+
catch (InvalidOperationException)
32+
{
33+
element = session.FindElementByAccessibilityId("AppName");
34+
}
35+
return element;
36+
}
37+
38+
internal static void DismissAlarmDialogIfThere(this WindowsDriver<WindowsElement> session)
39+
{
40+
try
41+
{
42+
session.FindElementByAccessibilityId("SecondaryButton").Click();
43+
}
44+
catch (InvalidOperationException)
45+
{
46+
}
47+
}
48+
}
49+
}

Tests/WebDriverAPI/AppiumAppLaunch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void Launch_ModernApp()
6666
// This will create a new calculator window and point the current active session to it
6767
session.LaunchApp();
6868
Assert.AreEqual(originalSessionId, session.SessionId);
69-
Assert.AreEqual(originalTitle, session.Title);
69+
Assert.IsTrue(originalTitle.Contains(session.Title));
7070
Assert.AreEqual(originalWindowHandlesCount + 1, session.WindowHandles.Count);
7171
Assert.AreNotEqual(originalLaunchedWindowHandle, session.CurrentWindowHandle);
7272

Tests/WebDriverAPI/Back.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void NavigateBack_ModernApp()
6666

6767
// Ensure alarms & clock are in Alarm Pivot view
6868
session.Navigate().Back();
69+
session.DismissAlarmDialogIfThere();
6970
session.FindElementByAccessibilityId("AlarmPivotItem").Click();
7071

7172
// Navigate to New Alarm view
@@ -74,6 +75,7 @@ public void NavigateBack_ModernApp()
7475

7576
// Navigate back to the original view
7677
session.Navigate().Back();
78+
session.DismissAlarmDialogIfThere();
7779
Assert.IsNotNull(session.FindElementByAccessibilityId("AlarmPivotItem"));
7880
}
7981

Tests/WebDriverAPI/ElementEquals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static void ClassCleanup()
4242
[TestMethod]
4343
public void CompareElements()
4444
{
45-
WindowsElement header = session.FindElementByAccessibilityId("AppNameTitle");
45+
WindowsElement header = session.FindCalculatorTitleByAccessibilityId();
4646
Assert.IsNotNull(header);
4747
Assert.IsFalse(header.Equals(referenceElement));
4848
Assert.IsFalse(referenceElement.Equals(header));

Tests/WebDriverAPI/ElementName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static void ClassCleanup()
3838
[TestMethod]
3939
public void GetElementTagName()
4040
{
41-
WindowsElement header = session.FindElementByAccessibilityId("AppNameTitle");
41+
WindowsElement header = session.FindCalculatorTitleByAccessibilityId();
4242
Assert.AreEqual("ControlType.Text", header.TagName);
4343

4444
WindowsElement navButton = session.FindElementByAccessibilityId("NavButton");

Tests/WebDriverAPI/Mouse.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void MouseClick()
7272
// Open a context menu on the application title bar to expose the context menu and verify that it contains minimize.
7373
// The context menu is parented on the desktop instead of the application. Thus, a desktop session is used to find it.
7474
// This command implicitly invoke /session/:sessionId/moveto and /session/:sessionId/click with button 2 parameter
75-
WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppNameTitle");
75+
WindowsElement appNameTitle = session.FindCalculatorTitleByAccessibilityId();
7676
session.Mouse.ContextClick(appNameTitle.Coordinates);
7777
Thread.Sleep(TimeSpan.FromSeconds(1.5));
7878
WindowsDriver<WindowsElement> desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);
@@ -100,7 +100,7 @@ public void MouseDoubleClick()
100100
Assert.IsTrue(maximizeButton.Text.Contains("Maximize"));
101101

102102
// Perform mouse double click on the title bar to maximize the Calculator window
103-
WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppNameTitle");
103+
WindowsElement appNameTitle = session.FindCalculatorTitleByAccessibilityId();
104104
session.Mouse.MouseMove(appNameTitle.Coordinates);
105105
session.Mouse.DoubleClick(null); // Pass null as this command omit the given parameter
106106
Thread.Sleep(TimeSpan.FromSeconds(1));
@@ -117,7 +117,7 @@ public void MouseDoubleClick()
117117
public void MouseDownMoveUp()
118118
{
119119
const int offset = 100;
120-
WindowsElement appNameTitle = session.FindElementByAccessibilityId("AppNameTitle");
120+
WindowsElement appNameTitle = session.FindCalculatorTitleByAccessibilityId();
121121
Assert.IsNotNull(appNameTitle);
122122

123123
// Save application window original position

0 commit comments

Comments
 (0)