Skip to content

Commit cf3b63f

Browse files
committed
Rename W3CWebDriver test project to WebDriverAPI to cover all supported API endpoints
Consolidate Appium specific API endpoint tests to the WebDriverAPI project Create a new README page for WebDriverAPI project Update Utility.CreateNewSession to support creating a session with launching argument Launch Edge browser in private mode to reduce load time and preserve machine state
1 parent 26b5471 commit cf3b63f

Some content is hidden

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

53 files changed

+189
-303
lines changed

Tests/Appium/Appium.csproj

-109
This file was deleted.

Tests/Appium/Appium.sln

-22
This file was deleted.

Tests/Appium/CommonTestSettings.cs

-31
This file was deleted.

Tests/Appium/Properties/AssemblyInfo.cs

-36
This file was deleted.

Tests/W3CWebDriver/packages.config

-8
This file was deleted.

Tests/W3CWebDriver/AppSessionBase/AlarmClockBase.cs renamed to Tests/WebDriverAPI/AppSessionBase/AlarmClockBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using OpenQA.Selenium.Appium.Windows;
1919
using OpenQA.Selenium.Remote;
2020

21-
namespace W3CWebDriver
21+
namespace WebDriverAPI
2222
{
2323
public class AlarmClockBase
2424
{

Tests/W3CWebDriver/AppSessionBase/CalculatorBase.cs renamed to Tests/WebDriverAPI/AppSessionBase/CalculatorBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using System;
2121
using System.Threading;
2222

23-
namespace W3CWebDriver
23+
namespace WebDriverAPI
2424
{
2525
public class CalculatorBase
2626
{

Tests/W3CWebDriver/AppSessionBase/CommonTestSettings.cs renamed to Tests/WebDriverAPI/AppSessionBase/CommonTestSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515
//******************************************************************************
1616

17-
namespace W3CWebDriver
17+
namespace WebDriverAPI
1818
{
1919
public class CommonTestSettings
2020
{

Tests/W3CWebDriver/AppSessionBase/EdgeBase.cs renamed to Tests/WebDriverAPI/AppSessionBase/EdgeBase.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using System;
2121
using System.Threading;
2222

23-
namespace W3CWebDriver
23+
namespace WebDriverAPI
2424
{
2525
public class EdgeBase
2626
{
@@ -38,8 +38,8 @@ public static void Setup(TestContext context)
3838
TearDown();
3939

4040
// Launch the Edge browser app
41-
session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId);
42-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
41+
session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private");
42+
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
4343
Assert.IsNotNull(session);
4444
Assert.IsNotNull(session.SessionId);
4545

Tests/W3CWebDriver/AppSessionBase/Utility.cs renamed to Tests/WebDriverAPI/AppSessionBase/Utility.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using OpenQA.Selenium.Remote;
1919
using System;
2020

21-
namespace W3CWebDriver
21+
namespace WebDriverAPI
2222
{
2323
public class Utility
2424
{
@@ -31,10 +31,16 @@ public class Utility
3131
CleanupOrphanedSession();
3232
}
3333

34-
public static WindowsDriver<WindowsElement> CreateNewSession(string appId)
34+
public static WindowsDriver<WindowsElement> CreateNewSession(string appId, string argument = null)
3535
{
3636
DesiredCapabilities appCapabilities = new DesiredCapabilities();
3737
appCapabilities.SetCapability("app", appId);
38+
39+
if (argument != null)
40+
{
41+
appCapabilities.SetCapability("appArguments", argument);
42+
}
43+
3844
return new WindowsDriver<WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
3945
}
4046

Tests/Appium/AppClose.cs renamed to Tests/WebDriverAPI/AppiumAppClose.cs

+14-19
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,57 @@
1414
//
1515
//******************************************************************************
1616

17-
using System;
1817
using Microsoft.VisualStudio.TestTools.UnitTesting;
1918
using OpenQA.Selenium.Appium.Windows;
20-
using OpenQA.Selenium.Remote;
19+
using System;
20+
using System.Threading;
2121

22-
namespace W3CWebDriver
22+
namespace WebDriverAPI
2323
{
2424
[TestClass]
2525
public class AppiumAppClose
2626
{
2727
private void CloseApplication(string applicationId)
2828
{
29-
DesiredCapabilities appCapabilities = new DesiredCapabilities();
30-
appCapabilities.SetCapability("app", applicationId);
31-
WindowsDriver<WindowsElement> session = new WindowsDriver<WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
32-
33-
Assert.IsNotNull(session);
29+
WindowsDriver<WindowsElement> session = Utility.CreateNewSession(applicationId);
3430
Assert.IsNotNull(session.SessionId);
35-
Assert.AreNotEqual(String.Empty, session.Title);
36-
Assert.AreNotEqual(String.Empty, session.CurrentWindowHandle);
37-
var originalWindowHandlesCount = session.WindowHandles.Count;
31+
Assert.AreNotEqual(string.Empty, session.Title);
32+
Assert.AreNotEqual(string.Empty, session.CurrentWindowHandle);
33+
Assert.IsTrue(session.WindowHandles.Count > 0);
3834

3935
session.CloseApp();
4036

41-
System.Threading.Thread.Sleep(3000); // Sleep for 3 second
42-
Assert.IsNotNull(session);
37+
Thread.Sleep(TimeSpan.FromSeconds(3));
4338
Assert.IsNotNull(session.SessionId);
44-
Assert.AreEqual(originalWindowHandlesCount - 1, session.WindowHandles.Count);
39+
Assert.AreEqual(0, session.WindowHandles.Count);
4540

4641
try
4742
{
4843
session.CloseApp(); // Attempt to close already closed app
4944
Assert.Fail("Exception should have been thrown");
5045
}
51-
catch (System.InvalidOperationException exception)
46+
catch (InvalidOperationException exception)
5247
{
53-
Assert.AreEqual("Currently selected window has been closed", exception.Message);
48+
Assert.AreEqual(ErrorStrings.NoSuchWindow, exception.Message);
5449
}
5550

5651
session.Quit();
5752
}
5853

5954
[TestMethod]
60-
public void CloseClassicApp()
55+
public void Close_ClassicApp()
6156
{
6257
CloseApplication(CommonTestSettings.NotepadAppId);
6358
}
6459

6560
[TestMethod]
66-
public void CloseModernApp()
61+
public void Close_ModernApp()
6762
{
6863
CloseApplication(CommonTestSettings.CalculatorAppId);
6964
}
7065

7166
[TestMethod]
72-
public void CloseSystemApp()
67+
public void Close_SystemApp()
7368
{
7469
CloseApplication(CommonTestSettings.ExplorerAppId);
7570
}

0 commit comments

Comments
 (0)