How you set the proxy is very much dependant on the browser. IE and
Safari will both use the same proxy that they normally do. If you're
using a preprepared profile in the Firefox driver then if you've set
the proxy already, it'll use whatever you've configured for that.
Otherwise:
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", '\"your.proxy.server\"");
profile.addAdditionalPreference("network.proxy.http_port", "8080");
profile.addAdditionalPreference("network.proxy.proxy.type", "1");
WebDriver driver = new FirefoxDriver(profile);
I'm not sure how the HtmlUnit driver can be configured once it's
instantiated, but you can always override the "newWebClient()" method
completely:
new HtmlUnitDriver() {
protected WebClient newWebClient() {
WebClient client = new WebClient(
BrowserVersion.INTERNET_EXPLORER_7_0,
"proxy host",
8080);
client.setThrowExceptionOnFailingStatusCode(true);
client.setJavaScriptEnabled(false);
client.setRedirectEnabled(true);
try {
client.setUseInsecureSSL(true);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
return client;
}
};
If there's demand for it, we can provide a mechanism to set the proxy
in a slightly more user-friendly fashion.
Regards,
Simon