Selenium Firefox Proxy Modes: PAC URL or Autodetect
Select automatic discovery or an explicit PAC URL in Selenium’s proxy capability when starting Firefox.
Firefox automation can request automatic proxy discovery without copying a personal browser profile into the test. Supply the intended proxy mode when creating the WebDriver session.
With Selenium’s Java API, an automatic-discovery configuration can be expressed as:
Proxy proxy = new Proxy().setAutodetect(true);
FirefoxOptions options = new FirefoxOptions().setProxy(proxy);
WebDriver driver = new FirefoxDriver(options);
These classes belong to Selenium. Discovery still depends on the browser machine’s network and applicable browser policy. It is not a promise that a WPAD service exists there.
When the PAC URL is already known, create a separate configuration with that URL instead:
Proxy proxy = new Proxy()
.setProxyAutoconfigUrl("https://config.example/proxy.pac");
FirefoxOptions options = new FirefoxOptions().setProxy(proxy);
Use one coherent mode. Manual HTTP and SSL proxy fields, automatic discovery and a specified PAC URL describe different ways of obtaining routes. Avoid combining them in one object and relying on an accidental precedence.
A PAC script can select several endpoints and direct exceptions by destination. Copying its last proxy address into manual settings replaces that policy with a fixed route. The explicit PAC mode preserves the script as the configuration input.
On a remote Grid, the browser node retrieves the script and connects to the selected proxy. A URL reachable from the test runner can be unreachable from that node. Keep the effective capability, script delivery and proxy connection evidence together when checking the setup.