Alfira
Alfira

Reputation: 113

Disable system proxy from java

My test script uses Selenium WebDriver with BrowserMob proxy server to simulate slow connection. Starting of the Internet Explorer WebDriver with BrowserMob proxy turns on system proxy. It affects to all connections to the internet (eclipse plugins update, mail corresponding and other apps). Therefore I need to disable system proxy at the end of test script. How to do this from java?

Note: stopping of BrowserMob proxy server doesn't disable system proxy settings.

Upvotes: 0

Views: 1395

Answers (1)

Alfira
Alfira

Reputation: 113

I found solution in Internet Explorer WebDriver. There is need to start web driver with IE specific desired capabilities like this:

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);

More info here https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities

Upvotes: 0

Related Questions