Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore SSL errors with playwright code generation

I am using the jest-playwright library (https://github.com/playwright-community/jest-playwright) to perform end-to-end testing. In the jest.config.js file you can set an option to ignore SSL errors:

contextOptions: {
   ignoreHTTPSErrors: true,
}

This works fine when running the tests with jest.
Now, I would want playwright to generate the code when clicking on website elements with the command npx playwright codegen example.com. However, playwright stops because of the SSL error when opening the website.

Is there an option to ignore SSL errors when using playwright code generation?

like image 355
kingkoen Avatar asked Dec 10 '25 10:12

kingkoen


1 Answers

Another option is to configure the test to ignore the HTTPS errors.

import { test } from "@playwright/test";

test.use({
  ignoreHTTPSErrors: true,
});

test("test", async ({ page }) => {
  await page.goto(
    "https://example.com/"
  );
});

NB - test.use... is what's included when running npx playwright codegen --ignore-https-errors.


UPDATE The setting can also be included in your playwright.config.ts file (see docs).

import { defineConfig } from '@playwright/test';
export default defineConfig({
  use: {
    ignoreHTTPSErrors: true,
  },
});
like image 146
robstarbuck Avatar answered Dec 14 '25 01:12

robstarbuck