Skip to content

Commit

Permalink
[java] Merge android specific parameters in chrome options (SeleniumH…
Browse files Browse the repository at this point in the history
…Q#14217)

* added androidOptions in merge method

* applied suggestions

* applying format.sh

* import assertEquals

* fix for importi Optional

---------

Co-authored-by: Diego Molina <[email protected]>
  • Loading branch information
2 people authored and dawid38 committed Jul 16, 2024
1 parent 9aa1a7f commit 5275d9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
19 changes: 7 additions & 12 deletions java/src/org/openqa/selenium/chromium/ChromiumOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.*;
import java.util.stream.Stream;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.SessionNotCreatedException;
Expand Down Expand Up @@ -320,10 +312,13 @@ protected void mergeInPlace(Capabilities capabilities) {
}
addExtensions(options.extensionFiles);
addEncodedExtensions(options.extensions);
if (options.binary != null) {
setBinary(options.binary);
}

Optional.ofNullable(options.binary).ifPresent(this::setBinary);

options.experimentalOptions.forEach(this::setExperimentalOption);

Optional.ofNullable(options.androidOptions)
.ifPresent(opts -> opts.forEach(this::setAndroidCapability));
}
}

Expand Down
15 changes: 15 additions & 0 deletions java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
import static org.assertj.core.api.InstanceOfAssertFactories.STRING;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.OFF;
import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.SEVERE;
import static org.openqa.selenium.remote.CapabilityType.ACCEPT_INSECURE_CERTS;
Expand Down Expand Up @@ -382,4 +383,18 @@ void shouldBeAbleToSetAnAndroidOption() {
.extractingByKey("androidActivity")
.isEqualTo("com.cheese.nom");
}

@Test
void shouldBeAbleToMergeAnAndroidOption() {
var original = new ChromeOptions();
original.setAndroidActivity("co_activity");
original.setAndroidPackage("co_package");
original.setExperimentalOption("experimental", "co_experimental");
original.addArguments("--co_argument");

var caps = new MutableCapabilities();
var merged = original.merge(caps);

assertEquals(original.asMap(), merged.asMap());
}
}
3 changes: 1 addition & 2 deletions py/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
import re
from textwrap import dedent, indent as tw_indent
import typing

import inflection # type: ignore



log_level = getattr(logging, os.environ.get('LOG_LEVEL', 'warning').upper())
Expand Down

0 comments on commit 5275d9f

Please sign in to comment.