Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/Chromium/ChromiumOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private string LoggingPreferencesChromeOption
/// <summary>
/// Gets or sets the location of the Chromium browser's binary executable file.
/// </summary>
public string BinaryLocation
public override string BinaryLocation
{
get { return this.binaryLocation; }
set { this.binaryLocation = value; }
Expand Down
10 changes: 10 additions & 0 deletions dotnet/src/webdriver/DriverOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ public bool UseStrictFileInteractability
set { this.useStrictFileInteractability = value; }
}

/// <summary>
/// Set or Get the location of the browser
/// Override in subclass
/// </summary>
public virtual string BinaryLocation
{
get { return null; }
set { throw new NotImplementedException(); }
}

/// <summary>
/// Provides a means to add additional capabilities not yet added as type safe options
/// for the specific browser driver.
Expand Down
9 changes: 9 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ public FirefoxProfile Profile
set { this.profile = value; }
}

/// <summary>
/// Gets or sets the path and file name of the Firefox browser executable.
/// </summary>
public override string BinaryLocation
{
get { return this.browserBinaryLocation; }
set { this.browserBinaryLocation = value; }
}

/// <summary>
/// Gets or sets the path and file name of the Firefox browser executable.
/// </summary>
Expand Down
39 changes: 15 additions & 24 deletions dotnet/src/webdriver/SeleniumManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static string DriverPath(DriverOptions options)
argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --browser-version {0}", options.BrowserVersion);
}

string browserBinary = BrowserBinary(options);
string browserBinary = options.BinaryLocation;
if (!string.IsNullOrEmpty(browserBinary))
{
argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --browser-path \"{0}\"", browserBinary);
Expand All @@ -112,31 +112,23 @@ public static string DriverPath(DriverOptions options)
}
}

return RunCommand(binaryFullPath, argsBuilder.ToString());
}

Dictionary<string, object> output = RunCommand(binaryFullPath, argsBuilder.ToString());
string browserPath = (string)output["browser_path"];
string driverPath = (string)output["driver_path"];

/// <summary>
/// Extracts the browser binary location from the vendor options when present. Only Chrome, Firefox, and Edge.
/// </summary>
private static string BrowserBinary(DriverOptions options)
{
ICapabilities capabilities = options.ToCapabilities();
string[] vendorOptionsCapabilities = { "moz:firefoxOptions", "goog:chromeOptions", "ms:edgeOptions" };
foreach (string vendorOptionsCapability in vendorOptionsCapabilities)
try
{
IDictionary<string, object> vendorOptions = capabilities.GetCapability(vendorOptionsCapability) as IDictionary<string, object>;

if (vendorOptions != null && vendorOptions.TryGetValue("binary", out object browserBinaryPath))
{
return browserBinaryPath as string;
}
options.BinaryLocation = browserPath;
options.BrowserVersion = null;
}
catch (NotImplementedException e)
{
// Cannot set Browser Location for this driver and that is ok
}

return null;
return driverPath;
}


/// <summary>
/// Executes a process with the given arguments.
/// </summary>
Expand All @@ -145,7 +137,7 @@ private static string BrowserBinary(DriverOptions options)
/// <returns>
/// the standard output of the execution.
/// </returns>
private static string RunCommand(string fileName, string arguments)
private static Dictionary<string, object> RunCommand(string fileName, string arguments)
{
Process process = new Process();
process.StartInfo.FileName = binaryFullPath;
Expand Down Expand Up @@ -187,12 +179,11 @@ private static string RunCommand(string fileName, string arguments)
}

string output = outputBuilder.ToString().Trim();
string result;
Dictionary<string, object> result;
try
{
Dictionary<string, object> deserializedOutput = JsonConvert.DeserializeObject<Dictionary<string, object>>(output, new ResponseValueJsonConverter());
Dictionary<string, object> deserializedResult = deserializedOutput["result"] as Dictionary<string, object>;
result = deserializedResult["message"] as string;
result = deserializedOutput["result"] as Dictionary<string, object>;
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/common/DevTools/DevToolsConsoleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class DevToolsConsoleTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyMessageAdded()
{
var domains = session.GetVersionSpecificDomains<V115.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
string consoleMessage = "Hello Selenium";

ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V115.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
EventHandler<V114.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
{
Assert.That(e.Message.Text, Is.EqualTo(consoleMessage));
sync.Set();
Expand Down
6 changes: 3 additions & 3 deletions dotnet/test/common/DevTools/DevToolsLogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class DevToolsLogTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyEntryAddedAndClearLog()
{
var domains = session.GetVersionSpecificDomains<V115.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V115.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
EventHandler<V114.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
{
Assert.That(e.Entry.Text.Contains("404"));
Assert.That(e.Entry.Level == V115.Log.LogEntryLevelValues.Error);
Assert.That(e.Entry.Level == V114.Log.LogEntryLevelValues.Error);
sync.Set();
};

Expand Down
Loading