Skip to content

Commit 7e0609f

Browse files
krmahadevanlukeis
authored andcommitted
Support ability to specify custom FF bin location (#2846)
Fixes #2845 Currently even though FirefoxDriver has the mechanisms to accept a custom location of firefox binary, the location is not honoured by GeckoDriverService. Fixing this by passing the location to geckodriver
1 parent b50bd7b commit 7e0609f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ private static final CommandExecutor createCommandExecutor(Capabilities desiredC
255255
if (isLegacy(desiredCapabilities)) {
256256
return new LazyCommandExecutor(binary, profile);
257257
}
258-
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
258+
GeckoDriverService.Builder builder;
259+
if (binary == null) {
260+
builder = new GeckoDriverService.Builder();
261+
} else {
262+
builder = new GeckoDriverService.Builder(binary);
263+
}
259264
builder.usingPort(0);
260265
return new DriverCommandExecutor(builder.build());
261266
}

java/client/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.openqa.selenium.WebDriverException;
2626
import org.openqa.selenium.net.PortProber;
2727
import org.openqa.selenium.firefox.internal.Executable;
28-
import org.openqa.selenium.os.CommandLine;
2928
import org.openqa.selenium.remote.service.DriverService;
3029

3130
import java.io.File;
@@ -79,6 +78,18 @@ protected void waitUntilAvailable() throws MalformedURLException {
7978
public static class Builder extends DriverService.Builder<
8079
GeckoDriverService, GeckoDriverService.Builder> {
8180

81+
private Executable binary;
82+
public Builder() {
83+
this(new FirefoxBinary());
84+
}
85+
86+
/**
87+
* @param binary - A custom location where the Firefox binary is available.
88+
*/
89+
public Builder(FirefoxBinary binary) {
90+
this.binary = binary.getExecutable();
91+
}
92+
8293
@Override
8394
protected File findDefaultExecutable() {
8495
return findExecutable(
@@ -95,9 +106,8 @@ protected ImmutableList<String> createArgs() {
95106
argsBuilder.add(String.format("--log-file=\"%s\"", getLogFile().getAbsolutePath()));
96107
}
97108
try {
98-
Executable firefoxExe = new Executable(null);
99109
argsBuilder.add("-b");
100-
argsBuilder.add(firefoxExe.getPath());
110+
argsBuilder.add(binary.getPath());
101111
} catch (WebDriverException e) {
102112
// Unable to find Firefox. GeckoDriver will be responsible for finding
103113
// Firefox on the PATH or via a capability.

0 commit comments

Comments
 (0)