Note that there are some explanatory texts on larger screens.

plurals
  1. POHtmlUnit proxy issue
    text
    copied!<p>It is about WebDriver, particularly HtmlUnitDriver and FirefoxWebDriver</p> <p>I used the same proxy settings for both HtmlUnitDriver and FirefoxWebDriver, but only FirefoxWebDriver works.</p> <p>What I got with HtmlUnitDriver was "Access denied" from the proxy server. I got a blank page when I didn't use proxy settings. I don't think it has anything to do with the username or password, because I got the same error if I didn't set the username or password.</p> <p>The following is my code, any idea would be appreciated. Thanks!</p> <pre><code>public WebDriver createHtmlUnitWebDriver() { HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver() { @Override protected WebClient modifyWebClient(WebClient client) { client.setProxyConfig(new ProxyConfig(PROXY_HOST, PROXY_PORT)); DefaultCredentialsProvider credentialsProvider = new DefaultCredentialsProvider(); credentialsProvider.addCredentials("username", "password"); credentialsProvider.addProxyCredentials("username", "password", PROXY_HOST, PROXY_PORT); client.setCredentialsProvider(credentialsProvider); return client; } }; htmlUnitDriver.setProxy(PROXY_HOST, PROXY_PORT); htmlUnitDriver.setJavascriptEnabled(true); return htmlUnitDriver; } public WebDriver createFirefoxWebDriver() { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("network.proxy.type", 1); firefoxProfile.setPreference("network.proxy.http", PROXY_HOST); firefoxProfile.setPreference("network.proxy.http_port", PROXY_PORT); firefoxProfile.setPreference("network.proxy.ssl", PROXY_HOST); firefoxProfile.setPreference("network.proxy.ssl_port", PROXY_PORT); firefoxProfile.setPreference("network.proxy.no_proxies_on", ""); return new FirefoxDriver(firefoxProfile); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload