Skip to content

Commit

Permalink
Adding additional .NET test targets for different browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed May 5, 2019
1 parent ae0b885 commit d657c07
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dotnet/test/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_nunit3_test")

net_nunit3_test(
name = "chrome",
SUPPORTED_BROWSERS = [
("chrome", "Chrome"),
("chromedev", "ChromeDev"),
("firefox", "Firefox"),
("firefoxnightly", "FirefoxNightly"),
("ie", "IE"),
("edge", "Edge"),
("safari", "Safari"),
("safaritechpreview", "SafariTechPreview"),
]

[net_nunit3_test(
name = "{}".format(target_name),
srcs = glob([
"*.cs",
"CustomDriverConfigs/*.cs",
"CustomTestAttributes/*.cs",
"Environment/*.cs",
"HTML5/*.cs",
Expand Down Expand Up @@ -32,9 +44,9 @@ net_nunit3_test(
"--agents=1",
"--params=ConfigFile=$(location appconfig.json)",
"--params=ActiveWebsiteConfig=HostsFileRedirect",
"--params=ActiveDriverConfig=Chrome",
"--params=ActiveDriverConfig={}".format(config_setting),
],
visibility = ["//visibility:public"],
out = "WebDriver.Common.Tests.dll",
dotnet_context_data = "@io_bazel_rules_dotnet//:net_context_data_net47"
)
) for (target_name, config_setting) in SUPPORTED_BROWSERS]
23 changes: 23 additions & 0 deletions dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace OpenQA.Selenium.Safari
{
// This is a simple wrapper class to create a SafariDriver that
// uses the technology preview implementation and has no parameters in the
// constructor.
public class DefaultSafariDriver : SafariDriver
{
public DefaultSafariDriver()
: this(DefaultService, new SafariOptions())
{
}

public DefaultSafariDriver(SafariDriverService service, SafariOptions options)
: base(service, options)
{
}

public static SafariDriverService DefaultService
{
get { return SafariDriverService.CreateDefaultService("/usr/bin"); }
}
}
}
25 changes: 25 additions & 0 deletions dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace OpenQA.Selenium.Chrome
{
public class DevChannelChromeDriver : ChromeDriver
{
public DevChannelChromeDriver(ChromeDriverService service)
: this(service, DefaultOptions)
{
}

public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
: base(service, options)
{
}

public static ChromeOptions DefaultOptions
{
get { return new ChromeOptions() { BinaryLocation = @"C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe" }; }
}
}
}
25 changes: 25 additions & 0 deletions dotnet/test/common/CustomDriverConfigs/NightlyFirefoxWebDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenQA.Selenium.Remote;

namespace OpenQA.Selenium.Firefox
{
// This is a simple wrapper class to create a FirefoxDriver that
// uses the Marionette implementation and has no parameters in the
// constructor.
public class NightlyFirefoxWebDriver : FirefoxDriver
{
public NightlyFirefoxWebDriver(FirefoxDriverService service)
: this(service, DefaultOptions)
{
}

public NightlyFirefoxWebDriver(FirefoxDriverService service, FirefoxOptions options)
: base(service, options)
{
}

public static FirefoxOptions DefaultOptions
{
get { return new FirefoxOptions() { BrowserExecutableLocation = @"C:\Program Files\Firefox Nightly\firefox.exe", AcceptInsecureCertificates = true }; }
}
}
}
25 changes: 25 additions & 0 deletions dotnet/test/common/CustomDriverConfigs/ReleaseFirefoxWebDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenQA.Selenium.Remote;

namespace OpenQA.Selenium.Firefox
{
// This is a simple wrapper class to create a FirefoxDriver that
// uses the Marionette implementation and has no parameters in the
// constructor.
public class ReleaseFirefoxWebDriver : FirefoxDriver
{
public ReleaseFirefoxWebDriver(FirefoxDriverService service)
: this(service, DefaultOptions)
{
}

public ReleaseFirefoxWebDriver(FirefoxDriverService service, FirefoxOptions options)
: base(service, options, RemoteWebDriver.DefaultCommandTimeout)
{
}

public static FirefoxOptions DefaultOptions
{
get { return new FirefoxOptions() { BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe", AcceptInsecureCertificates = true }; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace OpenQA.Selenium.Safari
{
// This is a simple wrapper class to create a SafariDriver that
// uses the technology preview implementation and has no parameters in the
// constructor.
public class SafariTechnologyPreviewDriver : SafariDriver
{
public SafariTechnologyPreviewDriver()
: this(DefaultService, DefaultOptions)
{
}

public SafariTechnologyPreviewDriver(SafariDriverService service, SafariOptions options)
: base(service, options)
{
}

public static SafariDriverService DefaultService
{
get { return SafariDriverService.CreateDefaultService("/Applications/Safari Technology Preview.app/Contents/MacOS"); }
}

public static SafariOptions DefaultOptions
{
get { return new SafariOptions(); }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using OpenQA.Selenium.Remote;

namespace OpenQA.Selenium.IE
{
// This is a simple wrapper class to create an InternetExplorerDriver that
// uses the enables RequireWindowFocus as the default input simplation.
public class WindowFocusInternetExplorerDriver : InternetExplorerDriver
{
private static string servicePath = string.Empty;

public WindowFocusInternetExplorerDriver(InternetExplorerDriverService service)
: this(service, DefaultOptions)
{
}

public WindowFocusInternetExplorerDriver(InternetExplorerDriverService service, InternetExplorerOptions options)
: base(service, options)
{
}

public static string ServicePath
{
get { return servicePath; }
set { servicePath = value; }
}

public static InternetExplorerDriverService DefaultService
{
get
{
InternetExplorerDriverService service;
if (string.IsNullOrEmpty(servicePath))
{
service = InternetExplorerDriverService.CreateDefaultService();
}
else
{
service = InternetExplorerDriverService.CreateDefaultService(servicePath);
}

// For debugging purposes, one can uncomment the following lines
// to generate a log from the driver executable. Please do not
// commit changes to this file with these lines uncommented.
// service.LogFile = @"iedriver.log";
// service.LoggingLevel = InternetExplorerDriverLogLevel.Debug;
return service;
}
}

public static InternetExplorerOptions DefaultOptions
{
get { return new InternetExplorerOptions() { RequireWindowFocus = true, UsePerProcessProxy = true }; }
}
}
}

0 comments on commit d657c07

Please sign in to comment.