microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.03k stars 3.54k forks source link

[Bug] Chromium proxy config throws on Windows #17252

Closed 22mSqRi closed 5 days ago

22mSqRi commented 1 year ago

I need test on authentication proxy, so I wrote proxy setting in playwright.config.ts . Proxy setting is successed on firefox, but chronium still have proxy error. What should I to do?

playwright version: 1.25.1

playwright.config.ts

const config : PlaywrightTestConfig = {
...
use:{
   proxy: {
      server: 'xxxxx',
      username: 'xxxxx',
      password: 'xxxxx',
   },
  },
}

chronium error message

browser.newContext: Browser needs to be launched with the global proxy, If all contexts override the proxy, global proxy will be never used and can be any string, for example "launch({ proxy: {server:'http://per-context'}})"
mxschmitt commented 1 year ago

I can repro, and its caused by the following upstream Chromium bug: https://crbug.com/1310057

Would be amazing if you could star ⭐ it on their side, then it's getting prioritized higher!

As a workaround, you can do the following:

const config: PlaywrightTestConfig = {
  use: {
    proxy: {
      server: 'xxxxx',
      username: 'xxxxx',
      password: 'xxxxx',
    },
    // workaround for: https://crbug.com/1310057
    launchOptions: {
      proxy: {
        server: 'per-context',
      },
    },
  },
}
helloworldcyj commented 9 months ago

playwright version: 1.39.0

I solved the error using the following configuration:

launchOptions: { args: ['--proxy-server=xxxxx'] }

mxschmitt commented 1 month ago

Note: Created a fix for it upstream https://chromium-review.googlesource.com/c/chromium/src/+/5688851 - keeping this issue open until we remove our per-context downstream hacks.