Skip to content

Commit 25aee6d

Browse files
committed
Update WebDriverAPI to use appium-dotnet-driver preview that has W3C WebDriver Actions API
1 parent 59dd132 commit 25aee6d

File tree

8 files changed

+35
-36
lines changed

8 files changed

+35
-36
lines changed

Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void Setup(TestContext context)
3939
Assert.IsNotNull(session.SessionId);
4040

4141
// Set implicit timeout to 2.5 seconds to make element search to retry every 500 ms for at most five times
42-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2.5));
42+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2.5);
4343

4444
// Initialize touch screen object
4545
touchScreen = new RemoteTouchScreen(session);

Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void Setup(TestContext context)
4040

4141
// Launch the Edge browser app
4242
session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private");
43-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
43+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
4444
Assert.IsNotNull(session);
4545
Assert.IsNotNull(session.SessionId);
4646

Tests/WebDriverAPI/Back.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void TestCleanup()
4141
public void NavigateBack_Browser()
4242
{
4343
session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private " + CommonTestSettings.EdgeAboutFlagsURL);
44-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
44+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
4545
Thread.Sleep(TimeSpan.FromSeconds(2.5));
4646
var originalTitle = session.Title;
4747
Assert.AreNotEqual(string.Empty, originalTitle);
@@ -62,7 +62,7 @@ public void NavigateBack_Browser()
6262
public void NavigateBack_ModernApp()
6363
{
6464
session = Utility.CreateNewSession(CommonTestSettings.AlarmClockAppId);
65-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
65+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
6666

6767
// Ensure alarms & clock are in Alarm Pivot view
6868
session.Navigate().Back();

Tests/WebDriverAPI/Forward.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void TestCleanup()
4141
public void NavigateForward_Browser()
4242
{
4343
session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private " + CommonTestSettings.EdgeAboutFlagsURL);
44-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
44+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
4545
Thread.Sleep(TimeSpan.FromSeconds(3));
4646
var originalTitle = session.Title;
4747
Assert.AreNotEqual(string.Empty, originalTitle);

Tests/WebDriverAPI/Screenshot.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
using System;
1818
using System.Drawing;
19-
using System.Drawing.Imaging;
2019
using System.IO;
2120
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using OpenQA.Selenium;
2222
using OpenQA.Selenium.Appium.Windows;
2323

2424
namespace WebDriverAPI
@@ -50,7 +50,7 @@ public void GetElementScreenshot()
5050
OpenQA.Selenium.Screenshot alarmPivotItemScreenshot1 = alarmPivotItem1.GetScreenshot();
5151

5252
// Save the AlarmPivotItem screenshot capture locally on the machine running the test
53-
alarmPivotItemScreenshot1.SaveAsFile(@"ScreenshotAlarmPivotItem.png", ImageFormat.Png);
53+
alarmPivotItemScreenshot1.SaveAsFile(@"ScreenshotAlarmPivotItem.png", ScreenshotImageFormat.Png);
5454

5555
// Using the Desktop session, locate the same AlarmPivotItem element in Alarms & Clock app to be captured
5656
desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);
@@ -142,14 +142,14 @@ public void GetScreenshot()
142142
OpenQA.Selenium.Screenshot alarmsClockScreenshot = session.GetScreenshot();
143143

144144
// Save the application screenshot capture locally on the machine running the test
145-
alarmsClockScreenshot.SaveAsFile(@"ScreenshotAlarmsClockApplication.png", ImageFormat.Png);
145+
alarmsClockScreenshot.SaveAsFile(@"ScreenshotAlarmsClockApplication.png", ScreenshotImageFormat.Png);
146146

147147
// Capture the entire desktop using the Desktop session
148148
desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);
149149
OpenQA.Selenium.Screenshot desktopScreenshot = desktopSession.GetScreenshot();
150150

151151
// Save the desktop screenshot capture locally on the machine running the test
152-
desktopScreenshot.SaveAsFile(@"ScreenshotDesktop.png", ImageFormat.Png);
152+
desktopScreenshot.SaveAsFile(@"ScreenshotDesktop.png", ScreenshotImageFormat.Png);
153153

154154
using (MemoryStream msScreenshot1 = new MemoryStream(alarmsClockScreenshot.AsByteArray))
155155
using (MemoryStream msScreenshot2 = new MemoryStream(notepadScreenshot.AsByteArray))

Tests/WebDriverAPI/Timeouts.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void ClassCleanup()
4545
[TestMethod]
4646
public void SetImplicitTimeout_FindElementFound()
4747
{
48-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs)));
48+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs));
4949
stopWatch.Restart();
5050
WindowsElement element = session.FindElementByAccessibilityId("AlarmPivotItem");
5151
stopWatch.Stop();
@@ -59,7 +59,7 @@ public void SetImplicitTimeout_FindElementFound()
5959
[TestMethod]
6060
public void SetImplicitTimeout_FindElementNotFound()
6161
{
62-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs)));
62+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs));
6363

6464
try
6565
{
@@ -80,7 +80,7 @@ public void SetImplicitTimeout_FindElementNotFound()
8080
[TestMethod]
8181
public void SetImplicitTimeout_FindElementsFound()
8282
{
83-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs)));
83+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs));
8484
stopWatch.Restart();
8585
var elements = session.FindElementsByAccessibilityId("AlarmPivotItem");
8686
stopWatch.Stop();
@@ -95,7 +95,7 @@ public void SetImplicitTimeout_FindElementsFound()
9595
[TestMethod]
9696
public void SetImplicitTimeout_FindElementsNotFound()
9797
{
98-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.Zero);
98+
session.Manage().Timeouts().ImplicitWait = TimeSpan.Zero;
9999
stopWatch.Restart();
100100
var elements = session.FindElementsByAccessibilityId("InvalidAccessibiliyId");
101101
stopWatch.Stop();
@@ -111,7 +111,7 @@ public void SetImplicitTimeoutError_BadValue()
111111
{
112112
try
113113
{
114-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Convert.ToDouble(-1)));
114+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(Convert.ToDouble(-1));
115115
Assert.Fail("Exception should have been thrown");
116116
}
117117
catch (InvalidOperationException exception)
@@ -125,7 +125,7 @@ public void SetImplicitTimeoutError_UnsupportedTypePageLoad()
125125
{
126126
try
127127
{
128-
session.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs)));
128+
session.Manage().Timeouts().PageLoad = TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs));
129129
Assert.Fail("Exception should have been thrown");
130130
}
131131
catch (WebDriverException exception)
@@ -139,7 +139,7 @@ public void SetImplicitTimeoutError_UnsupportedTypeScript()
139139
{
140140
try
141141
{
142-
session.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs)));
142+
session.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromMilliseconds(Convert.ToDouble(implicitTimeoutMs));
143143
Assert.Fail("Exception should have been thrown");
144144
}
145145
catch (WebDriverException exception)

Tests/WebDriverAPI/WebDriverAPI.csproj

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,28 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38-
<Reference Include="appium-dotnet-driver, Version=3.0.0.2, Culture=neutral, processorArchitecture=MSIL">
39-
<HintPath>packages\Appium.WebDriver.3.0.0.2\lib\net45\appium-dotnet-driver.dll</HintPath>
40-
<Private>True</Private>
38+
<Reference Include="appium-dotnet-driver, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>packages\Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview\lib\net45\appium-dotnet-driver.dll</HintPath>
4140
</Reference>
42-
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
43-
<HintPath>packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
44-
<Private>True</Private>
41+
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
42+
<HintPath>packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
4543
</Reference>
4644
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
4745
<HintPath>packages\Microsoft.VisualStudio.QualityTools.UnitTestFramework.Updated.15.0.26228\lib\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
4846
<Private>True</Private>
4947
</Reference>
50-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
51-
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
52-
<Private>True</Private>
48+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
49+
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5350
</Reference>
5451
<Reference Include="System" />
52+
<Reference Include="System.Configuration" />
5553
<Reference Include="System.Drawing" />
5654
<Reference Include="System.XML" />
57-
<Reference Include="WebDriver, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
58-
<HintPath>packages\Selenium.WebDriver.3.0.1\lib\net40\WebDriver.dll</HintPath>
59-
<Private>True</Private>
55+
<Reference Include="WebDriver, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
56+
<HintPath>packages\Selenium.WebDriver.3.8.0\lib\net45\WebDriver.dll</HintPath>
6057
</Reference>
61-
<Reference Include="WebDriver.Support, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
62-
<HintPath>packages\Selenium.Support.3.0.1\lib\net40\WebDriver.Support.dll</HintPath>
63-
<Private>True</Private>
58+
<Reference Include="WebDriver.Support, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
59+
<HintPath>packages\Selenium.Support.3.8.0\lib\net45\WebDriver.Support.dll</HintPath>
6460
</Reference>
6561
</ItemGroup>
6662
<Choose>
@@ -72,6 +68,8 @@
7268
<Otherwise />
7369
</Choose>
7470
<ItemGroup>
71+
<Compile Include="Actions.cs" />
72+
<Compile Include="ActionsTouch.cs" />
7573
<Compile Include="AppiumAppClose.cs" />
7674
<Compile Include="AppiumAppLaunch.cs" />
7775
<Compile Include="AppSessionBase\Utility.cs" />
@@ -109,6 +107,7 @@
109107
<Compile Include="TouchFlick.cs" />
110108
<Compile Include="TouchDoubleClick.cs" />
111109
<Compile Include="TouchLongClick.cs" />
110+
<Compile Include="ActionsPen.cs" />
112111
<Compile Include="TouchScroll.cs" />
113112
<Compile Include="TouchClick.cs" />
114113
<Compile Include="Title.cs" />

Tests/WebDriverAPI/packages.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Appium.WebDriver" version="3.0.0.2" targetFramework="net45" />
4-
<package id="Castle.Core" version="3.3.3" targetFramework="net45" />
3+
<package id="Castle.Core" version="4.2.1" targetFramework="net45" />
54
<package id="Microsoft.VisualStudio.QualityTools.UnitTestFramework.Updated" version="15.0.26228" targetFramework="net45" />
6-
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
7-
<package id="Selenium.Support" version="3.0.1" targetFramework="net45" />
8-
<package id="Selenium.WebDriver" version="3.0.1" targetFramework="net45" />
5+
<package id="Microsoft.WinAppDriver.Appium.WebDriver" version="1.0.1-Preview" targetFramework="net45" />
6+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
7+
<package id="Selenium.Support" version="3.8.0" targetFramework="net45" />
8+
<package id="Selenium.WebDriver" version="3.8.0" targetFramework="net45" />
99
</packages>

0 commit comments

Comments
 (0)