Skip to content

Commit

Permalink
[dotnet] remove hard coded service parameters from test environment (#…
Browse files Browse the repository at this point in the history
…12343)

[dotnet] remove hard coded service parameters from test environment setup
  • Loading branch information
titusfortner authored Jul 12, 2023
1 parent 7589a65 commit 3fbd0e5
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 443 deletions.
2 changes: 1 addition & 1 deletion dotnet/test/common/AlertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void ShouldAllowTheUserToGetTheTextOfAPrompt()
}

[Test]
public void AlertShouldNotAllowAdditionalCommandsIfDimissed()
public void AlertShouldNotAllowAdditionalCommandsIfDismissed()
{
driver.Url = CreateAlertPage("cheese");

Expand Down
106 changes: 0 additions & 106 deletions dotnet/test/common/AvailableLogsTest.cs

This file was deleted.

11 changes: 6 additions & 5 deletions dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ namespace OpenQA.Selenium.Safari
public class DefaultSafariDriver : SafariDriver
{
public DefaultSafariDriver()
: this(DefaultService, new SafariOptions())
: base(DefaultOptions)
{
}

public DefaultSafariDriver(SafariDriverService service, SafariOptions options)
: base(service, options)
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public DefaultSafariDriver(SafariOptions options)
: base(options)
{
}

public static SafariDriverService DefaultService
public static SafariOptions DefaultOptions
{
get { return SafariDriverService.CreateDefaultService("/usr/bin"); }
get { return new SafariOptions(); }
}
}
}
19 changes: 6 additions & 13 deletions dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
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()
: base(DefaultOptions)
{
}

public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
: base(service, options)
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public DevChannelChromeDriver(ChromeOptions options)
: base(options)
{
}

public static ChromeOptions DefaultOptions
{
// The below path to the Chrome Developer Channel executable is obviously hard-coded.
// On non-Windows OSes, and for custom install locations, you will need to add a
// property to the below options: BinaryLocation = <path to Chrome.exe>
get { return new ChromeOptions() { BinaryLocation = @"C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe", AcceptInsecureCertificates = true }; }
get { return new ChromeOptions() { BrowserVersion = "dev" }; }
}
}
}
40 changes: 5 additions & 35 deletions dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenQA.Selenium.Edge
{
public class DevChannelEdgeDriver : EdgeDriver
{
private static string servicePath = string.Empty;

public DevChannelEdgeDriver()
: this(DefaultService, DefaultOptions)
: base(DefaultOptions)
{
}

public DevChannelEdgeDriver(EdgeDriverService service, EdgeOptions options)
: base(service, options)
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public DevChannelEdgeDriver(EdgeOptions options)
: base(options)
{
}

public static EdgeOptions DefaultOptions
{
get {
// The below path to the Edge Developer Channel executable is obviously hard-coded.
// On non-Windows OSes, and for custom install locations, you will need to add a
// property to the below options: BinaryLocation = <path to MSEdge.exe>
return new EdgeOptions()
{
BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe"
};
}
}

public static EdgeDriverService DefaultService
{
get
{
EdgeDriverService service = EdgeDriverService.CreateDefaultService(ServicePath);
return service;
}
}

public static string ServicePath
{
get { return servicePath; }
set { servicePath = value; }
get { return new EdgeOptions() { BrowserVersion = "dev" }; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
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 EdgeInternetExplorerModeDriver : InternetExplorerDriver
{
private static string servicePath = string.Empty;

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

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

public static string ServicePath
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public EdgeInternetExplorerModeDriver(InternetExplorerOptions options)
: base(options)
{
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, AttachToEdgeChrome = true, EdgeExecutablePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" }; }
get { return new InternetExplorerOptions() { RequireWindowFocus = true, UsePerProcessProxy = true, AttachToEdgeChrome = true }; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
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 NightlyChannelFirefoxDriver : FirefoxDriver
{
public NightlyChannelFirefoxDriver(FirefoxDriverService service)
: this(service, DefaultOptions)
public NightlyChannelFirefoxDriver()
: base(DefaultOptions)
{
}

public NightlyChannelFirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
: base(service, options)
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public NightlyChannelFirefoxDriver(FirefoxOptions options)
: base(options)
{
}

public static FirefoxOptions DefaultOptions
{
// The below path to the Firefox Nightly Channel executable is obviously hard-coded.
// On non-Windows OSes, and for custom install locations, you will need to add a
// property to the below options: BrowserExecutableLocation = <path to Firefox.exe>
get { return new FirefoxOptions() { BrowserExecutableLocation = @"C:\Program Files\Firefox Nightly\firefox.exe", AcceptInsecureCertificates = true }; }
get { return new FirefoxOptions() { BrowserVersion = "nightly" }; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ namespace OpenQA.Selenium.Safari
public class SafariTechnologyPreviewDriver : SafariDriver
{
public SafariTechnologyPreviewDriver()
: this(DefaultService, DefaultOptions)
: base(DefaultOptions)
{
}

public SafariTechnologyPreviewDriver(SafariDriverService service, SafariOptions options)
: base(service, options)
// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public SafariTechnologyPreviewDriver(SafariOptions options)
: base(options)
{
}

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

public static SafariOptions DefaultOptions
{
get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace OpenQA.Selenium.Chrome
{
public class StableChannelChromeDriver : ChromeDriver
{
public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
: base(service, options)
public StableChannelChromeDriver()
: base(DefaultOptions)
{
}

// Required for dynamic setting with `EnvironmentManager.Instance.CreateDriverInstance(options)`
public StableChannelChromeDriver(ChromeOptions options)
: base(options)
{
}

Expand Down
Loading

0 comments on commit 3fbd0e5

Please sign in to comment.