forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding language bindings for Microsoft Edge browser
Includes client langauge bindings for Java and .NET. Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
- Loading branch information
Showing
15 changed files
with
824 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// <copyright file="EdgeDriver.cs" company="Microsoft"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using OpenQA.Selenium.Internal; | ||
using OpenQA.Selenium.Remote; | ||
|
||
namespace OpenQA.Selenium.Edge | ||
{ | ||
/// <summary> | ||
/// Provides a mechanism to write tests against Edge | ||
/// </summary> | ||
public class EdgeDriver : RemoteWebDriver | ||
{ | ||
#region Constructors | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class. | ||
/// </summary> | ||
public EdgeDriver() | ||
: this(new EdgeOptions()) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified options. | ||
/// </summary> | ||
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> | ||
public EdgeDriver(EdgeOptions options) | ||
: this(EdgeDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified driver service. | ||
/// </summary> | ||
/// <param name="service">The <see cref="EdgeDriverService"/> used to initialize the driver.</param> | ||
public EdgeDriver(EdgeDriverService service) | ||
: this(service, new EdgeOptions()) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified path | ||
/// to the directory containing EdgeDriver.exe. | ||
/// </summary> | ||
/// <param name="EdgeDriverDirectory">The full path to the directory containing EdgeDriver.exe.</param> | ||
public EdgeDriver(string EdgeDriverDirectory) | ||
: this(EdgeDriverDirectory, new EdgeOptions()) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified path | ||
/// to the directory containing EdgeDriver.exe and options. | ||
/// </summary> | ||
/// <param name="EdgeDriverDirectory">The full path to the directory containing EdgeDriver.exe.</param> | ||
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> | ||
public EdgeDriver(string EdgeDriverDirectory, EdgeOptions options) | ||
: this(EdgeDriverDirectory, options, RemoteWebDriver.DefaultCommandTimeout) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified path | ||
/// to the directory containing EdgeDriver.exe, options, and command timeout. | ||
/// </summary> | ||
/// <param name="EdgeDriverDirectory">The full path to the directory containing EdgeDriver.exe.</param> | ||
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> | ||
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> | ||
public EdgeDriver(string EdgeDriverDirectory, EdgeOptions options, TimeSpan commandTimeout) | ||
: this(EdgeDriverService.CreateDefaultService(EdgeDriverDirectory), options, commandTimeout) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified | ||
/// <see cref="EdgeDriverService"/> and options. | ||
/// </summary> | ||
/// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> | ||
/// <param name="options">The <see cref="EdgeOptions"/> used to initialize the driver.</param> | ||
public EdgeDriver(EdgeDriverService service, EdgeOptions options) | ||
: this(service, options, RemoteWebDriver.DefaultCommandTimeout) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified <see cref="EdgeDriverService"/>. | ||
/// </summary> | ||
/// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> | ||
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> | ||
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> | ||
public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) | ||
: base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities()) | ||
{ | ||
} | ||
#endregion | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// <copyright file="EdgeDriverService.cs" company="Microsoft"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Text; | ||
using OpenQA.Selenium.Internal; | ||
|
||
namespace OpenQA.Selenium.Edge | ||
{ | ||
/// <summary> | ||
/// Exposes the service provided by the native MicrosoftWebDriver executable. | ||
/// </summary> | ||
public sealed class EdgeDriverService : DriverService | ||
{ | ||
private const string MicrosoftWebDriverServiceFileName = "MicrosoftWebDriver.exe"; | ||
private static readonly Uri MicrosoftWebDriverDownloadUrl = new Uri("http://download.microsoft.com/download/6/D/7/6D7B7A44-B792-4CB4-AEC3-4C190EB99F85/MicrosoftWebDriver.msi"); | ||
private string logPath = string.Empty; | ||
private string urlPathPrefix = string.Empty; | ||
private string portServerAddress = string.Empty; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the EdgeDriverService class. | ||
/// </summary> | ||
/// <param name="executablePath">The full path to the EdgeDriver executable.</param> | ||
/// <param name="executableFileName">The file name of the EdgeDriver executable.</param> | ||
/// <param name="port">The port on which the EdgeDriver executable should listen.</param> | ||
private EdgeDriverService(string executablePath, string executableFileName, int port) | ||
: base(executablePath, port, executableFileName, MicrosoftWebDriverDownloadUrl) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a default instance of the EdgeDriverService. | ||
/// </summary> | ||
/// <returns>A EdgeDriverService that implements default settings.</returns> | ||
public static EdgeDriverService CreateDefaultService() | ||
{ | ||
string serviceDirectory = DriverService.FindDriverServiceExecutable(MicrosoftWebDriverServiceFileName, MicrosoftWebDriverDownloadUrl); | ||
return CreateDefaultService(serviceDirectory); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a default instance of the EdgeDriverService using a specified path to the EdgeDriver executable. | ||
/// </summary> | ||
/// <param name="driverPath">The directory containing the EdgeDriver executable.</param> | ||
/// <returns>A EdgeDriverService using a random port.</returns> | ||
public static EdgeDriverService CreateDefaultService(string driverPath) | ||
{ | ||
return CreateDefaultService(driverPath, MicrosoftWebDriverServiceFileName); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a default instance of the EdgeDriverService using a specified path to the EdgeDriver executable with the given name. | ||
/// </summary> | ||
/// <param name="driverPath">The directory containing the EdgeDriver executable.</param> | ||
/// <param name="driverExecutableFileName">The name of the EdgeDriver executable file.</param> | ||
/// <returns>A EdgeDriverService using a random port.</returns> | ||
public static EdgeDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) | ||
{ | ||
return new EdgeDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a default instance of the EdgeDriverService using a specified path to the EdgeDriver executable with the given name and listening port. | ||
/// </summary> | ||
/// <param name="driverPath">The directory containing the EdgeDriver executable.</param> | ||
/// <param name="driverExecutableFileName">The name of the EdgeDriver executable file</param> | ||
/// <param name="port">The port number on which the driver will listen</param> | ||
/// <returns></returns> | ||
public static EdgeDriverService CreateDefaultService(string driverPath, string driverExecutableFileName, int port) | ||
{ | ||
return new EdgeDriverService(driverPath, driverExecutableFileName, port); | ||
} | ||
} | ||
} |
Oops, something went wrong.