Search code examples
playwrightplaywright-test

How do I ignore HTTPS errors for devices in playwright?


I am writing playwright tests and testing them on my local machine, which has SSL but the cert is often giving errors.

I want to ignore all HTTPS-related errors when developing on my local machine. (I will do final testing in the cloud with a valid cert.)

For browsers, you can add ignoreHTTPSErrors to contextOptions like this:

const config: PlaywrightTestConfig = {
  projects: [
    {
      name: 'Safari MacBook Air',
      use: {
        browserName: 'webkit',
        viewport: {
          width: 2560,
          height: 1620,
        },
        contextOptions: {
          ignoreHTTPSErrors: true,
        },
      },
    },

However, I can't find a similar option for devices:

{
  name: 'iPhone 6/7/8',
  use: devices['iPhone 8'],
},

How can I ignore HTTPS errors with a device?


Solution

  • Haven't actually tried, but as I see it, can't you use it as well in your mobile project?

    For example, in your config:

        /* Test against mobile viewports. */
        {
          name: 'Mobile Chrome',
          use: {
            ...devices['Pixel 5'],
            contextOptions: {
              ignoreHTTPSErrors: true
            },
          },
        },