2016-11-28 82 views
1

我的测试脚本使用Selenium WebDriver和BrowserMob代理服务器来模拟慢速连接。使用BrowserMob代理启动Internet Explorer WebDriver会打开系统代理。它会影响所有到互联网的连接(eclipse插件更新,邮件对应和其他应用程序)。因此,我需要在测试脚本结束时禁用系统代理。如何从java中做到这一点?从java中禁用系统代理

注意:停止BrowserMob代理服务器不会禁用系统代理设置。

回答

1

我在Internet Explorer WebDriver中找到了解决方案。 有必要启动网络驱动器,具有这样的IE特定需要的功能:

BrowserMobProxy server = new BrowserMobProxyServer(); 
server.start(); 

Proxy proxy = ClientUtil.createSeleniumProxy(server); 

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); 
capabilities.setCapability(InternetExplorerDriver.IE_USE_PRE_PROCESS_PROXY, true); 
capabilities.setCapability(CapabilityType.PROXY, proxy); 

WebDriver driver = new InternetExplorerDriver(capabilities); 

更多的信息在这里https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities