本文整理了Java中org.openqa.selenium.Proxy.setSocksProxy()
方法的一些代码示例,展示了Proxy.setSocksProxy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Proxy.setSocksProxy()
方法的具体详情如下:
包路径:org.openqa.selenium.Proxy
类名称:Proxy
方法名:setSocksProxy
[英]Specifies which proxy to use for SOCKS.
[中]指定用于袜子的代理。
代码示例来源:origin: qaprosoft/carina
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;
}
代码示例来源:origin: org.seleniumhq.selenium/selenium-api
setSocksProxy((String) raw.get("socksProxy"));
代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin
proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY).setSocksProxy(PROXY);
cap.setCapability(CapabilityType.PROXY, proxy);
代码示例来源:origin: zc-zh-001/ShadowSocks-Share
proxy.setSocksProxy(proxyServer);
} else {
proxy.setHttpProxy(proxyServer);
代码示例来源:origin: kg.apc/jmeter-plugins-webdriver
/**
* 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);
}
内容来源于网络,如有侵权,请联系作者删除!