Skip to content

Commit 2d941a0

Browse files
authored
Use all provided options while merging them for Firefox (#13582)
* Use all provided options while merging them for Firefox This fix addresses the discrepancy that we have in methods of processing browser options for Chromium and Firefox. In the case of Chromium, if the option name doesn't match any of previously processed, we add it anyway. It doesn't happen for Firefox. So in the case when one option is set in stereotype, but other is provided in capabilities this second one is missed from the result. Unit test updated to cover this case. * fixed formatting in SessionCapabilitiesMutatorTest
1 parent 1eb2c8c commit 2d941a0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

java/src/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ private Map<String, Object> mergeFirefoxOptions(
171171
Map<String, Object> stereotypeOptions, Map<String, Object> capsOptions) {
172172
Map<String, Object> toReturn = new HashMap<>(stereotypeOptions);
173173

174+
List<String> handledOptions = List.of("args", "prefs", "profile", "log", "binary");
175+
174176
for (Map.Entry<String, Object> entry : capsOptions.entrySet()) {
175177
String name = entry.getKey();
176178
Object value = entry.getValue();
@@ -215,6 +217,14 @@ private Map<String, Object> mergeFirefoxOptions(
215217
Map<String, Object> logLevelMap = (Map<String, Object>) value;
216218
toReturn.put("log", logLevelMap);
217219
}
220+
221+
if (name.equals("binary") && !stereotypeOptions.containsKey("binary")) {
222+
toReturn.put(name, value);
223+
}
224+
225+
if (!handledOptions.contains(name)) {
226+
toReturn.put(name, value);
227+
}
218228
}
219229

220230
return toReturn;

java/test/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutatorTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ void shouldMergeFirefoxSpecificOptionsFromStereotypeAndCaps() {
238238
stereotypeOptions.put("log", debugLog);
239239

240240
stereotypeOptions.put("profile", "profile-string");
241+
stereotypeOptions.put("androidDeviceSerial", "emulator-5556");
241242

242243
stereotype =
243244
new ImmutableCapabilities(
@@ -260,6 +261,7 @@ void shouldMergeFirefoxSpecificOptionsFromStereotypeAndCaps() {
260261
capabilityOptions.put("profile", "different-profile-string");
261262

262263
capabilityOptions.put("binary", "/path/to/caps/binary");
264+
capabilityOptions.put("androidPackage", "com.android.chrome");
263265

264266
capabilities =
265267
new ImmutableCapabilities(
@@ -304,6 +306,20 @@ void shouldMergeFirefoxSpecificOptionsFromStereotypeAndCaps() {
304306
.extractingByKey("profile")
305307
.asInstanceOf(STRING)
306308
.isEqualTo("different-profile-string");
309+
310+
assertThat(modifiedCapabilities)
311+
.extractingByKey("moz:firefoxOptions")
312+
.asInstanceOf(MAP)
313+
.extractingByKey("androidDeviceSerial")
314+
.asInstanceOf(STRING)
315+
.isEqualTo("emulator-5556");
316+
317+
assertThat(modifiedCapabilities)
318+
.extractingByKey("moz:firefoxOptions")
319+
.asInstanceOf(MAP)
320+
.extractingByKey("androidPackage")
321+
.asInstanceOf(STRING)
322+
.isEqualTo("com.android.chrome");
307323
}
308324

309325
@Test

0 commit comments

Comments
 (0)