Skip to content

Commit b129262

Browse files
committed
Implementing another GeckoDriverService factory method that creates a service based on capabilities. This method is used by grid to honor firefox_binary capability.
1 parent 1f852e6 commit b129262

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.common.io.ByteStreams;
2626

2727
//import org.apache.commons.io.output.NullOutputStream;
28+
import org.openqa.selenium.Capabilities;
2829
import org.openqa.selenium.WebDriverException;
2930
import org.openqa.selenium.net.PortProber;
3031
import org.openqa.selenium.remote.service.DriverService;
@@ -70,6 +71,27 @@ public static GeckoDriverService createDefaultService() {
7071
return new Builder().usingAnyFreePort().build();
7172
}
7273

74+
static GeckoDriverService createDefaultService(Capabilities caps) {
75+
Builder builder = new Builder().usingAnyFreePort();
76+
77+
Object binary = caps.getCapability(FirefoxDriver.BINARY);
78+
if (binary != null) {
79+
FirefoxBinary actualBinary;
80+
if (binary instanceof FirefoxBinary) {
81+
actualBinary = (FirefoxBinary) binary;
82+
} else if (binary instanceof String) {
83+
actualBinary = new FirefoxBinary(new File(String.valueOf(binary)));
84+
} else {
85+
throw new IllegalArgumentException(
86+
"Expected binary to be a string or a binary: " + binary);
87+
}
88+
89+
builder.usingFirefoxBinary(actualBinary);
90+
}
91+
92+
return new Builder().build();
93+
}
94+
7395
@Override
7496
protected void waitUntilAvailable() throws MalformedURLException {
7597
PortProber.waitForPortUp(getUrl().getPort(), 20, SECONDS);

0 commit comments

Comments
 (0)