From e92c363068298d0abb55a011495590c65d6d5aef Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Wed, 23 Oct 2013 00:47:13 +0400 Subject: [PATCH] Removing use of WindowsProxyManager from InternetExplorerDriver, proxy management is implemented in IEDriverServer now --- .../selenium/ie/InternetExplorerDriver.java | 88 ++----------------- 1 file changed, 6 insertions(+), 82 deletions(-) diff --git a/java/client/src/org/openqa/selenium/ie/InternetExplorerDriver.java b/java/client/src/org/openqa/selenium/ie/InternetExplorerDriver.java index 25e68630a092a..d4d3c1d67fb7c 100644 --- a/java/client/src/org/openqa/selenium/ie/InternetExplorerDriver.java +++ b/java/client/src/org/openqa/selenium/ie/InternetExplorerDriver.java @@ -17,14 +17,11 @@ package org.openqa.selenium.ie; -import com.google.common.base.Predicate; import com.google.common.base.Throwables; -import com.google.common.collect.Maps; import org.openqa.selenium.Capabilities; import org.openqa.selenium.OutputType; import org.openqa.selenium.Platform; -import org.openqa.selenium.Proxy; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.browserlaunchers.WindowsProxyManager; @@ -36,8 +33,6 @@ import org.openqa.selenium.remote.service.DriverCommandExecutor; import java.io.File; -import java.util.HashSet; -import java.util.Set; import static org.openqa.selenium.remote.CapabilityType.PROXY; @@ -146,31 +141,11 @@ public class InternetExplorerDriver extends RemoteWebDriver implements TakesScre */ public final static String IE_SWITCHES = "ie.browserCommandLineSwitches"; - /** - * @deprecated please set this option as True and allow IEDriverServer sets up proxy. - * In next releases it will be set to True by default. - * - * Capability that defines used proxy setter. Currently it's False by default. - * - * False means WindowsProxyManager will be used for setting proxy settings. - * True means IEDriverServer will be used for setting proxy settings. - * - * Be note that using both variants in concurrent drivers at the same node - * may lead to undefined behaviour. - */ - @Deprecated - public final static String IE_SET_PROXY_BY_SERVER = "ie.setProxyByServer"; - /** * Port which is used by default. */ private final static int DEFAULT_PORT = 0; - /** - * To set proxy by server or not. - */ - private final boolean setProxyByServer; - /** * Proxy manager. */ @@ -201,27 +176,22 @@ public InternetExplorerDriver(WindowsProxyManager proxy, InternetExplorerDriverS capabilities = DesiredCapabilities.internetExplorer(); } - setProxyByServer = useServerForProxy(capabilities); + proxyManager = proxy; - if (proxy == null) { - proxyManager = setupProxy(capabilities); - } else { - proxyManager = proxy; - } if (service == null) { service = setupService(capabilities, port); } - run(service, capabilities, port); + run(service, capabilities); } - private void run(InternetExplorerDriverService service, Capabilities capabilities, int port) { + private void run(InternetExplorerDriverService service, Capabilities capabilities) { assertOnWindows(); prepareProxy(capabilities); setCommandExecutor(new DriverCommandExecutor(service)); - startSession(updateCapabilities(capabilities)); + startSession(capabilities); } @Override @@ -290,32 +260,16 @@ private InternetExplorerDriverService setupService(Capabilities caps, int port) } } - InternetExplorerDriverService service = builder.build(); - - return service; + return builder.build(); } catch (IllegalStateException ex) { throw Throwables.propagate(ex); } } - private WindowsProxyManager setupProxy(Capabilities caps) { - // do not create proxy manager if it's not requested. see issue 4135 - // also do not create proxy manager if it will be managed by server. - if (caps == null || caps.getCapability(PROXY) == null || setProxyByServer) { - return null; - } - - return new WindowsProxyManager( - /* boolean customPACappropriate */ true, - /* String sessionId */ "webdriver-ie", - /* int port */ 0, - /* int portDriversShouldContact */ 0); - } - private void prepareProxy(Capabilities caps) { // do not prepare proxy manager if it will be managed by server. - if (caps == null || caps.getCapability(PROXY) == null || setProxyByServer) { + if (caps == null || caps.getCapability(PROXY) == null || proxyManager == null) { return; } @@ -333,34 +287,4 @@ public void run() { Runtime.getRuntime().addShutdownHook(cleanupThread); } - /** - * Determine to use server for setting proxy or not. - * - * @param caps capabilties - * @return to use or not - */ - private boolean useServerForProxy(Capabilities caps) { - if (caps == null || caps.getCapability(IE_SET_PROXY_BY_SERVER) == null) { - return false; - } - - return (Boolean) caps.getCapability(IE_SET_PROXY_BY_SERVER); - } - - /** - * if proxy will be not managed by server overwrite proxy capability so - * server will do nothing. - */ - private Capabilities updateCapabilities(Capabilities capabilities) { - if (capabilities == null || capabilities.getCapability(PROXY) == null || setProxyByServer) { - return capabilities; - } - - Proxy proxy = new Proxy(); - proxy.setProxyType(Proxy.ProxyType.SYSTEM); - ((DesiredCapabilities) capabilities).setCapability(PROXY, proxy); - - return capabilities; - } - } \ No newline at end of file