【发布时间】:2016-08-31 11:52:55
【问题描述】:
我正在为 Java 使用 selenium 3.0.0-beta2。我无法设置代理。我已经尝试了很多东西,但没有任何效果。我尝试了以下,
`String PROXY = "localhost:8080";
DesiredCapabilities.
Proxy proxy = new Proxy();
proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY)
.setSocksProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
driver = new FirefoxDriver(cap);`
我也试过这个:
`FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "someproxy");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);`
我在火狐上使用 geckodriver。我将它定义为这样的系统属性System.setProperty("webdriver.gecko.driver", ".\\lib\\geckodriver.exe");
我还发现here 尚不支持代理功能。有没有办法设置代理?
【问题讨论】:
标签: java selenium firefox proxy