Skip to content

Commit

Permalink
Merge pull request #121 from thc202/firefox-proxy
Browse files Browse the repository at this point in the history
Fix Firefox proxy settings
  • Loading branch information
psiinon authored Sep 11, 2017
2 parents 71bc03a + 8c3ec21 commit 655b79a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/main/java/org/mozilla/zest/core/v1/ZestClientLaunch.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,32 @@ public String invoke(ZestRuntime runtime) throws ZestClientFailException {
}

if ("Firefox".equalsIgnoreCase(this.browserType)) {
FirefoxOptions firefoxOptions = new FirefoxOptions();
if (isHeadless()) {
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addArguments(HEADLESS_ARG);
firefoxOptions.addTo(cap);
}

if (!httpProxy.isEmpty()) {
String[] proxyData = httpProxy.split(":");
String proxyAddress = proxyData[0];
int proxyPort = Integer.parseInt(proxyData[1]);

// Some issues prevent the PROXY capability from being properly applied:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1282873
// https://bugzilla.mozilla.org/show_bug.cgi?id=1369827
// For now set the preferences manually:
firefoxOptions.addPreference("network.proxy.type", 1);
firefoxOptions.addPreference("network.proxy.http", proxyAddress);
firefoxOptions.addPreference("network.proxy.http_port", proxyPort);
firefoxOptions.addPreference("network.proxy.ssl", proxyAddress);
firefoxOptions.addPreference("network.proxy.ssl_port", proxyPort);
firefoxOptions.addPreference("network.proxy.share_proxy_settings", true);
firefoxOptions.addPreference("network.proxy.no_proxies_on", "");
// And remove the PROXY capability:
cap.setCapability(CapabilityType.PROXY, (Object) null);
}
firefoxOptions.addTo(cap);

driver = new FirefoxDriver(cap);
} else if ("Chrome".equalsIgnoreCase(this.browserType)) {
if (isHeadless()) {
Expand Down

0 comments on commit 655b79a

Please sign in to comment.