Playwright use proxy for API-call not for browsers

28 views Asked by At

I'm working on a test in Playwrigt/Typescript. The test open a webpage (wikth chromium) and does not need any proxy setting. Somewhere in the test I do an API-call and this call needs to respect the proxy settings. When I include

launchOptions: {
    // Browser proxy option is required for Chromium on Windows.
    proxy: { server: 'per-context' }
},
proxy: {
  server: 'https://xx.xxx.xxx.xx:80',
  bypass: 'localhost'
},

in the playwright.config.ts the testpart which opens the webpage fails.

Error: page.goto: net::ERR_PROXY_CONNECTION_FAILED at https://...../registreren
Call log:
    - navigating to "https://...../registreren", waiting until "load"`

The projects section in the playwright.config.ts looks like:

projects: [
{
  name: 'chromium',
  use:{ ...devices['Desktop Chrome'], 
        headless: false, 
        video: 'on'
      },   
},

When I don't add the proxy settings to the playwright.config.ts, the API-call fails with a timeout.

How should the setting be to make sure that browser action ignore the proxy-settings and the API-call respects them?

I tried including/excluding the proxy-settings.

I tried including/excluding the proxy: { server: 'per-context' } setting.

0

There are 0 answers