From cc79de69690f01b7c6a7679931de3678f4bccf92 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 28 Jun 2022 11:42:37 +0200 Subject: [PATCH] [java] Putting all valid IEOptions only in se:ieOptions This is part of the work being done to remove JWP support from Java. Fixes #10822 --- .../selenium/ie/InternetExplorerOptions.java | 21 +++++++++-------- .../selenium/remote/RemoteWebDriver.java | 23 ------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java b/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java index 4be0e4f7cb4ff..23efe3b4d1a80 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java @@ -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(" ")); @@ -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)) { @@ -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()); } }); } diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index f2fb19b9c6a31..6035eac1d3a3d 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -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; @@ -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 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(); @@ -705,7 +683,6 @@ private void checkNonW3CCapabilities(Capabilities capabilities) { List invalid = capabilities.asMap().keySet() .stream() .filter(key -> !(new AcceptedW3CCapabilityKeys().test(key))) - .filter(key -> !IE_CAPABILITY_NAMES.contains(key)) .collect(Collectors.toList()); if (!invalid.isEmpty()) {