diff --git a/dotnet/test/common/BUILD.bazel b/dotnet/test/common/BUILD.bazel index dc70e94ce2451..57181bb146b91 100644 --- a/dotnet/test/common/BUILD.bazel +++ b/dotnet/test/common/BUILD.bazel @@ -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", @@ -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] diff --git a/dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs b/dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs new file mode 100644 index 0000000000000..eadc7ef556319 --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs @@ -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"); } + } + } +} diff --git a/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs b/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs new file mode 100644 index 0000000000000..7212e582ba592 --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs @@ -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" }; } + } + } +} diff --git a/dotnet/test/common/CustomDriverConfigs/NightlyFirefoxWebDriver.cs b/dotnet/test/common/CustomDriverConfigs/NightlyFirefoxWebDriver.cs new file mode 100644 index 0000000000000..d4da5efc259bf --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/NightlyFirefoxWebDriver.cs @@ -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 }; } + } + } +} diff --git a/dotnet/test/common/CustomDriverConfigs/ReleaseFirefoxWebDriver.cs b/dotnet/test/common/CustomDriverConfigs/ReleaseFirefoxWebDriver.cs new file mode 100644 index 0000000000000..72e958ca96e14 --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/ReleaseFirefoxWebDriver.cs @@ -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 }; } + } + } +} diff --git a/dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs b/dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs new file mode 100644 index 0000000000000..01b51bf09b6b8 --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs @@ -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(); } + } + } +} diff --git a/dotnet/test/common/CustomDriverConfigs/WindowFocusInternetExplorerDriver.cs b/dotnet/test/common/CustomDriverConfigs/WindowFocusInternetExplorerDriver.cs new file mode 100644 index 0000000000000..b08d0bf49927d --- /dev/null +++ b/dotnet/test/common/CustomDriverConfigs/WindowFocusInternetExplorerDriver.cs @@ -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 }; } + } + } +}