protected Proxy setupProxy() { ProxyPool.setupBrowserMobProxy(); SystemProxy.setupProxy(); String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty()) { org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); String proxyAddress = String.format("%s:%s", proxyHost, proxyPort); if (protocols.contains("http")) { LOGGER.info(String.format("Http proxy will be set: %s:%s", proxyHost, proxyPort)); proxy.setHttpProxy(proxyAddress); } if (protocols.contains("https")) { LOGGER.info(String.format("Https proxy will be set: %s:%s", proxyHost, proxyPort)); proxy.setSslProxy(proxyAddress); } if (protocols.contains("ftp")) { LOGGER.info(String.format("FTP proxy will be set: %s:%s", proxyHost, proxyPort)); proxy.setFtpProxy(proxyAddress); } if (protocols.contains("socks")) { LOGGER.info(String.format("Socks proxy will be set: %s:%s", proxyHost, proxyPort)); proxy.setSocksProxy(proxyAddress); } return proxy; } return null; }
setSocksProxy((String) raw.get("socksProxy"));
proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY).setSocksProxy(PROXY); cap.setCapability(CapabilityType.PROXY, proxy);
proxy.setSocksProxy(proxyServer); } else { proxy.setHttpProxy(proxyServer);
/** * This returns a {@link Proxy} with HTTP, HTTPS and FTP hosts and ports configured as specified. * * * @param httpProxy is the http proxy host and port * @param httpsProxy is the https proxy host and port * @param ftpProxy is the ftp proxy host and port * @param socksProxy is the socks proxy host and port * @param noProxy is a comma separated list of hosts that will bypass the proxy * * @return a proxy object with the hosts manually specified. */ public Proxy getManualProxy(ProxyHostPort httpProxy, ProxyHostPort httpsProxy, ProxyHostPort ftpProxy, ProxyHostPort socksProxy, String noProxy) { return new Proxy() .setProxyType(Proxy.ProxyType.MANUAL) .setHttpProxy(httpProxy.toUnifiedForm()) .setSslProxy(httpsProxy.toUnifiedForm()) .setFtpProxy(ftpProxy.toUnifiedForm()) .setSocksProxy(socksProxy.toUnifiedForm()) .setNoProxy(noProxy); }