proxy = Proxy.extractFrom(desiredCapabilities);
switch (proxy.getProxyType()) { case MANUAL: if (proxy.getHttpProxy() != null && !proxy.getHttpProxy().isEmpty()) { //< HTTP proxy argsBuilder.add("--proxy-type=http"); argsBuilder.add(String.format("--proxy=%s", proxy.getHttpProxy())); } else if (proxy.getSocksProxy() != null && !proxy.getSocksProxy().isEmpty()) { //< SOCKS5 proxy argsBuilder.add("--proxy-type=socks5"); argsBuilder.add(String.format("--proxy=%s", proxy.getSocksProxy())); if (proxy.getSocksUsername() != null && !proxy.getSocksUsername().isEmpty() && proxy.getSocksPassword() != null && !proxy.getSocksPassword().isEmpty()) { argsBuilder.add(String.format("--proxy-auth=%s:%s", proxy.getSocksUsername(), proxy.getSocksPassword()));
public Proxy getProxy() { Proxy proxy = null; if (proxyHost != null) { proxy = new Proxy(); proxy.setProxyType(ProxyType.MANUAL); proxy.setHttpProxy(proxyHost); proxy.setFtpProxy(proxyHost); proxy.setSslProxy(proxyHost); } return proxy; }
private WebDriver createWebDriver(Context context) { Proxy proxy = new Proxy(); if (StringUtils.isNotBlank(proxyHttp)) { proxy.setHttpProxy(proxyHttp); proxy.setFtpProxy(proxyFtp); proxy.setSslProxy(proxySsl); proxy.setProxyAutoconfigUrl(proxyAutoConfigUrl); proxy.setAutodetect(proxyAutoDetect);
public void in(DesiredCapabilities capabilities) { String proxyUrl = ThucydidesSystemProperty.SERENITY_PROXY_HTTP.from(environmentVariables); String proxyPort = ThucydidesSystemProperty.SERENITY_PROXY_HTTP_PORT.from(environmentVariables); String sslProxy = ThucydidesSystemProperty.SERENITY_PROXY_SSL.from(environmentVariables, proxyUrl); String sslProxyPort = ThucydidesSystemProperty.SERENITY_PROXY_SSL_PORT.from(environmentVariables); Proxy proxy = new Proxy(); if ((proxyUrl != null) && (!proxyUrl.isEmpty())) { JsonObject json = new JsonObject(); if (StringUtils.isNotEmpty(proxyUrl)) { proxy.setHttpProxy(proxyUrl + ":"+ proxyPort); } if (StringUtils.isNotEmpty(sslProxy)) { proxy.setSslProxy(sslProxy + ":"+ sslProxyPort); } if (StringUtils.isNotEmpty(sslProxyPort)) { json.addProperty("sslProxyPort", sslProxyPort); } capabilities.setCapability(CapabilityType.PROXY, proxy); } } }
public Proxy getProxy() { ProxyConfig proxyConfig = getProxyConfig(); Proxy proxy = new Proxy(); proxy.setProxyType(proxyConfig.getType()); if (proxyConfig.getType() == ProxyType.PAC) { proxy.setProxyAutoconfigUrl(proxyConfig.getPac()); // manual proxy configuration } else if (proxyConfig.getType() == ProxyType.MANUAL) { proxy.setHttpProxy(proxyConfig.getAddressAndPort()); proxy.setSslProxy(proxyConfig.getAddressAndPort()); proxy.setFtpProxy(proxyConfig.getAddressAndPort()); if (proxyConfig.getLogin() != null && proxyConfig.getPassword() != null) { proxy.setSocksUsername(proxyConfig.getLogin()); proxy.setSocksPassword(proxyConfig.getPassword()); } if (proxyConfig.getExclude() != null) { proxy.setNoProxy(proxyConfig.getExclude().replace(";", ",")); } } return proxy; }
public Proxy(Map<String, ?> raw) { if (raw.containsKey("proxyType") && raw.get("proxyType") != null) { setProxyType(ProxyType.valueOf(((String) raw.get("proxyType")).toUpperCase())); setFtpProxy((String) raw.get("ftpProxy")); setHttpProxy((String) raw.get("httpProxy")); if (rawData instanceof List) { setNoProxy(String.join(", ", (List) rawData)); } else { setNoProxy((String) rawData); setSslProxy((String) raw.get("sslProxy")); setSocksProxy((String) raw.get("socksProxy")); setSocksVersion((Integer) raw.get("socksVersion")); setSocksUsername((String) raw.get("socksUsername")); setSocksPassword((String) raw.get("socksPassword")); setProxyAutoconfigUrl((String) raw.get("proxyAutoconfigUrl")); setAutodetect((Boolean) raw.get("autodetect"));
public void setHttpProxy(String proxyHost) { if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) { proxy = new Proxy(); proxy.setHttpProxy(proxyHost); capabilities.setCapability(CapabilityType.PROXY, proxy); } }
/** * Returns the Proxy this client wraps, in form of a Selenium Proxy configuration object. * * @return Selenium Proxy configuration object */ public Proxy asSeleniumProxy() { Proxy seleniumProxyConfig = new Proxy(); seleniumProxyConfig.setProxyType(Proxy.ProxyType.MANUAL); seleniumProxyConfig.setHttpProxy(asHostAndPort()); return seleniumProxyConfig; }
Proxy sanitize(Object proxy) { if (proxy != null) { if (proxy instanceof Proxy) { return (Proxy) proxy; } else if (proxy instanceof Map) { return new Proxy((Map<String, ?>) proxy); } } return null; } },
@Override public Proxy seleniumProxy() throws UnknownHostException { return server.asSeleniumProxy() .setHttpProxy(String.format("%s:%d", proxyManager.getServer(), getPort())) .setSslProxy(String.format("%s:%d", proxyManager.getServer(), getPort())); }
/** * This will not use a proxy and expects a direct connection to the internet. * * @return a proxy object that does not use proxies. */ public Proxy getDirectProxy() { return new Proxy() .setProxyType(Proxy.ProxyType.DIRECT); }
public void setSslProxy(String proxyHost) { if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) { proxy = new Proxy(); proxy.setSslProxy(proxyHost); capabilities.setCapability(CapabilityType.PROXY, proxy); } }
Proxy proxy = new Proxy(); proxy.setSocksProxy(proxyServer); } else { proxy.setHttpProxy(proxyServer);
/** * If the proxy can be configured using a PAC file at a URL, set this value to the location of this PAC file. * * @param pacUrl is the url to the Proxy PAC file * * @return a proxy object with its proxies configured automatically using a PAC file. */ public Proxy getConfigUrlProxy(String pacUrl) { return new Proxy() .setProxyType(Proxy.ProxyType.PAC) .setProxyAutoconfigUrl(pacUrl); }
/** * This is a proxy which will have its settings automatically configured. * * @return a proxy object which will try to automatically detect the proxy settings. */ public Proxy getAutodetectProxy() { return new Proxy() .setProxyType(Proxy.ProxyType.AUTODETECT) .setAutodetect(true); }
public void setFtpProxy(String proxyHost) { if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) { proxy = new Proxy(); proxy.setFtpProxy(proxyHost); capabilities.setCapability(CapabilityType.PROXY, proxy); } }
@Override public int hashCode() { return Objects.hash( getProxyType(), isAutodetect(), getFtpProxy(), getHttpProxy(), getNoProxy(), getSslProxy(), getSocksProxy(), getSocksVersion(), getSocksUsername(), getSocksPassword(), getProxyAutoconfigUrl()); } }
server = new BrowserMobProxyServer(); server.start(0); Proxy proxy = ClientUtil.createSeleniumProxy(server); proxy.setSslProxy("trustAllSSLCertificates");
String PROXY = "localhost:8080"; ProxyServer server = new ProxyServer(8080); server.start(); Proxy proxy = server.seleniumProxy(); proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.PROXY, proxy); WebDriver driver = new FirefoxDriver(capabilities); server.newHar("yahoo.com"); driver.get("http://yahoo.com"); Har har = server.getHar(); FileOutputStream fos = new FileOutputStream("C:\\Users\\ner\\output.txt"); har.writeTo(fos); server.stop(); driver.quit();