Skip to content

Commit bc4c207

Browse files
committed
Fix an issue where setting the binary causes Firefox to be unable to start
Turns out we weren't populating things properly.
1 parent a509aa8 commit bc4c207

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,27 @@ public FirefoxDriver(Capabilities desiredCapabilities) {
166166

167167
private static FirefoxOptions getFirefoxOptions(Capabilities capabilities) {
168168
FirefoxOptions options = new FirefoxOptions();
169-
if (capabilities != null) {
170-
Object rawOptions = capabilities.getCapability(FIREFOX_OPTIONS);
171-
if (rawOptions != null) {
172-
if (rawOptions instanceof Map) {
173-
try {
174-
@SuppressWarnings("unchecked")
175-
Map<String, Object> map = (Map<String, Object>) rawOptions;
176-
rawOptions = FirefoxOptions.fromJsonMap(map);
177-
} catch (IOException e) {
178-
throw new WebDriverException(e);
179-
}
180-
}
181-
if (rawOptions != null && !(rawOptions instanceof FirefoxOptions)) {
182-
throw new WebDriverException("Firefox option was set, but is not a FirefoxOption: " + rawOptions);
169+
170+
if (capabilities == null) {
171+
return options;
172+
}
173+
174+
Object rawOptions = capabilities.getCapability(FIREFOX_OPTIONS);
175+
if (rawOptions != null) {
176+
if (rawOptions instanceof Map) {
177+
try {
178+
@SuppressWarnings("unchecked")
179+
Map<String, Object> map = (Map<String, Object>) rawOptions;
180+
rawOptions = FirefoxOptions.fromJsonMap(map);
181+
} catch (IOException e) {
182+
throw new WebDriverException(e);
183183
}
184-
options = (FirefoxOptions) rawOptions;
185184
}
185+
if (rawOptions != null && !(rawOptions instanceof FirefoxOptions)) {
186+
throw new WebDriverException(
187+
"Firefox option was set, but is not a FirefoxOption: " + rawOptions);
188+
}
189+
options = (FirefoxOptions) rawOptions;
186190
}
187191
return options;
188192
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,18 @@ public FirefoxOptions addDesiredCapabilities(Capabilities desiredCapabilities) {
335335
}
336336
profile = suggestedProfile;
337337
}
338+
Object binary = desiredCapabilities.getCapability(BINARY);
339+
if (binary != null) {
340+
if (binary instanceof File) {
341+
setBinary(((File) binary).toPath());
342+
} else if (binary instanceof FirefoxBinary) {
343+
setBinary((FirefoxBinary) binary);
344+
} else if (binary instanceof Path) {
345+
setBinary((Path) binary);
346+
} else if (binary instanceof String) {
347+
setBinary((String) binary);
348+
}
349+
}
338350

339351
return this;
340352
}

0 commit comments

Comments
 (0)