'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 1:[1]

I tested this with version 1.22.0 and it works:

package test;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.options.Proxy;

public class Example {
  public static void main(String[] args) {
    try (Playwright playwright = Playwright.create()) {
      BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions();
      launchOptions.headless = false;
      launchOptions.setProxy(new Proxy("localhost:8888"));
      Browser browser = playwright.chromium().launch(launchOptions);
      Page page = browser.newPage();
      page.navigate("http://playwright.dev");
      System.out.println(page.title());
    }
  }
}

The launchOptions don't cause the system proxy setting to be set. Values on your screenshot must have been entered before.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1