To enable proxy with Firefox browser you need to create a new profile and pass it to the driver as follows:
-
Setting up HTTP proxy:
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", "localhost"); profile.setPreference("network.proxy.http_port", 3128); WebDriver driver = new FirefoxDriver(profile);
-
Setting up SSL proxy:
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.ssl", "localhost"); profile.setPreference("network.proxy.ssl_port", 3128); WebDriver driver = new FirefoxDriver(profile);