Skip to content

Commit

Permalink
[java] Putting all valid IEOptions only in se:ieOptions
Browse files Browse the repository at this point in the history
This is part of the work being done to remove JWP
support from Java.

Fixes SeleniumHQ#10822
  • Loading branch information
diemol committed Jun 28, 2022
1 parent 334a103 commit cc79de6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
21 changes: 11 additions & 10 deletions java/src/org/openqa/selenium/ie/InternetExplorerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ private InternetExplorerOptions amend(String optionName, Object value) {

@Override
public void setCapability(String key, Object value) {
super.setCapability(key, value);

if (IE_SWITCHES.equals(key)) {
if (value instanceof List) {
value = ((List<?>) value).stream().map(Object::toString).collect(Collectors.joining(" "));
Expand All @@ -247,6 +245,9 @@ public void setCapability(String key, Object value) {

if (CAPABILITY_NAMES.contains(key)) {
ieOptions.put(key, value);
} else if (!IE_OPTIONS.equals(key)) {
// Regular, top level value
super.setCapability(key, value);
}

if (IE_OPTIONS.equals(key)) {
Expand All @@ -257,17 +258,17 @@ public void setCapability(String key, Object value) {
} else if (value instanceof Capabilities) {
streamFrom = ((Capabilities) value).asMap();
} else {
throw new IllegalArgumentException("Value must not be null for " + key);
throw new IllegalArgumentException(
"Value for " + key + " must be of type Map or Capabilities");
}

streamFrom.entrySet().stream()
.filter(e -> CAPABILITY_NAMES.contains(e.getKey()))
.filter(e -> e.getValue() != null)
.forEach(e -> {
if (IE_SWITCHES.equals(e.getKey())) {
setCapability(e.getKey(), Arrays.asList((e.getValue().toString()).split(" ")));
.filter(entry -> CAPABILITY_NAMES.contains(entry.getKey()))
.filter(entry -> entry.getValue() != null)
.forEach(entry -> {
if (IE_SWITCHES.equals(entry.getKey())) {
setCapability(entry.getKey(), Arrays.asList((entry.getValue().toString()).split(" ")));
} else {
setCapability(e.getKey(), e.getValue());
setCapability(entry.getKey(), entry.getValue());
}
});
}
Expand Down
23 changes: 0 additions & 23 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -105,27 +104,6 @@ public class RemoteWebDriver implements WebDriver,
PrintsPage,
TakesScreenshot {

// TODO: Remove in 4.4 when all IE caps go inside se:ieOptions
private static final List<String> IE_CAPABILITY_NAMES = Arrays.asList(
"browserAttachTimeout",
"elementScrollBehavior",
"enablePersistentHover",
"ie.enableFullPageScreenshot",
"ie.forceCreateProcessApi",
"ie.forceShellWindowsApi",
"ie.ensureCleanSession",
"ie.browserCommandLineSwitches",
"ie.usePerProcessProxy",
"ignoreZoomSetting",
"initialBrowserUrl",
"ignoreProtectedModeSettings",
"requireWindowFocus",
"ie.fileUploadDialogTimeout",
"nativeEvents",
"ie.useLegacyFileUploadDialogHandling",
"ie.edgechromium",
"ie.edgepath");

// TODO: This static logger should be unified with the per-instance localLogs
private static final Logger logger = Logger.getLogger(RemoteWebDriver.class.getName());
private final ElementLocation elementLocation = new ElementLocation();
Expand Down Expand Up @@ -705,7 +683,6 @@ private void checkNonW3CCapabilities(Capabilities capabilities) {
List<String> invalid = capabilities.asMap().keySet()
.stream()
.filter(key -> !(new AcceptedW3CCapabilityKeys().test(key)))
.filter(key -> !IE_CAPABILITY_NAMES.contains(key))
.collect(Collectors.toList());

if (!invalid.isEmpty()) {
Expand Down

0 comments on commit cc79de6

Please sign in to comment.