Skip to content

Commit 4a17ec3

Browse files
iampopovichdiemol
andauthored
[java] Merge android specific parameters in chrome options (#14217)
* added androidOptions in merge method * applied suggestions * applying format.sh * import assertEquals * fix for importi Optional --------- Co-authored-by: Diego Molina <[email protected]>
1 parent 9aa1a7f commit 4a17ec3

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

java/src/org/openqa/selenium/chromium/ChromiumOptions.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@
2424
import java.io.File;
2525
import java.io.IOException;
2626
import java.nio.file.Files;
27-
import java.util.ArrayList;
28-
import java.util.Arrays;
29-
import java.util.Base64;
30-
import java.util.Collections;
31-
import java.util.HashMap;
32-
import java.util.List;
33-
import java.util.Map;
34-
import java.util.Set;
35-
import java.util.TreeMap;
27+
import java.util.*;
3628
import java.util.stream.Stream;
3729
import org.openqa.selenium.Capabilities;
3830
import org.openqa.selenium.SessionNotCreatedException;
@@ -320,10 +312,13 @@ protected void mergeInPlace(Capabilities capabilities) {
320312
}
321313
addExtensions(options.extensionFiles);
322314
addEncodedExtensions(options.extensions);
323-
if (options.binary != null) {
324-
setBinary(options.binary);
325-
}
315+
316+
Optional.ofNullable(options.binary).ifPresent(this::setBinary);
317+
326318
options.experimentalOptions.forEach(this::setExperimentalOption);
319+
320+
Optional.ofNullable(options.androidOptions)
321+
.ifPresent(opts -> opts.forEach(this::setAndroidCapability));
327322
}
328323
}
329324

java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
2424
import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
2525
import static org.assertj.core.api.InstanceOfAssertFactories.STRING;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
2627
import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.OFF;
2728
import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.SEVERE;
2829
import static org.openqa.selenium.remote.CapabilityType.ACCEPT_INSECURE_CERTS;
@@ -382,4 +383,18 @@ void shouldBeAbleToSetAnAndroidOption() {
382383
.extractingByKey("androidActivity")
383384
.isEqualTo("com.cheese.nom");
384385
}
386+
387+
@Test
388+
void shouldBeAbleToMergeAnAndroidOption() {
389+
var original = new ChromeOptions();
390+
original.setAndroidActivity("co_activity");
391+
original.setAndroidPackage("co_package");
392+
original.setExperimentalOption("experimental", "co_experimental");
393+
original.addArguments("--co_argument");
394+
395+
var caps = new MutableCapabilities();
396+
var merged = original.merge(caps);
397+
398+
assertEquals(original.asMap(), merged.asMap());
399+
}
385400
}

0 commit comments

Comments
 (0)