Search code examples
playwrightplaywright-java

How to set proxy for Chromium on Windows with Playwright Java?


I'm trying to use a proxy for Chromium on Windows:

BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions();
launchOptions.setProxy(new Proxy("localhost:8888"));

Browser browser = Playwright.create().chromium().launch(launchOptions);

In the settings I see that the proxy has been set properly, but the option Use proxyserver is set to false.

Windows' proxy settings

How to change that?


Solution

  • Try the --proxy-server command line switch:

    launchOptions.setArgs(List.of("--proxy-server=http://localhost:8888"))
    

    (via)