diff --git a/nodejs/docs/chrome-extensions.mdx b/nodejs/docs/chrome-extensions.mdx index 58600712ef4..a0b1c340890 100644 --- a/nodejs/docs/chrome-extensions.mdx +++ b/nodejs/docs/chrome-extensions.mdx @@ -13,7 +13,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; Extensions only work in Chrome / Chromium launched with a persistent context. Use custom browser args at your own risk, as some of them may break Playwright functionality. ::: -The snippet below retrieves the [background page](https://developer.chrome.com/extensions/background_pages) of a [Manifest v2](https://developer.chrome.com/docs/extensions/mv2/) extension whose source is located in `./my-extension`. +The snippet below retrieves the [service worker](https://developer.chrome.com/docs/extensions/develop/concepts/service-workers) of a [Manifest v3](https://developer.chrome.com/docs/extensions/develop/migrate) extension whose source is located in `./my-extension`. Note the use of the `chromium` channel that allows to run extensions in headless mode. Alternatively, you can launch the browser in headed mode. @@ -30,11 +30,11 @@ const { chromium } = require('playwright'); `--load-extension=${pathToExtension}` ] }); - let [backgroundPage] = browserContext.backgroundPages(); - if (!backgroundPage) - backgroundPage = await browserContext.waitForEvent('backgroundpage'); + let [serviceWorker] = browserContext.serviceWorkers(); + if (!serviceWorker) + serviceWorker = await browserContext.waitForEvent('serviceworker'); - // Test the background page as you would any other page. + // Test the service worker as you would any other worker. await browserContext.close(); })(); ``` @@ -68,19 +68,12 @@ export const test = base.extend<{ await context.close(); }, extensionId: async ({ context }, use) => { - /* - // for manifest v2: - let [background] = context.backgroundPages() - if (!background) - background = await context.waitForEvent('backgroundpage') - */ - // for manifest v3: - let [background] = context.serviceWorkers(); - if (!background) - background = await context.waitForEvent('serviceworker'); + let [serviceWorker] = context.serviceWorkers(); + if (!serviceWorker) + serviceWorker = await context.waitForEvent('serviceworker'); - const extensionId = background.url().split('/')[2]; + const extensionId = serviceWorker.url().split('/')[2]; await use(extensionId); }, }); diff --git a/nodejs/docs/intro.mdx b/nodejs/docs/intro.mdx index 8f5ce8463a4..b2828218a3f 100644 --- a/nodejs/docs/intro.mdx +++ b/nodejs/docs/intro.mdx @@ -245,7 +245,7 @@ pnpm exec playwright --version ## System requirements -- Latest version of Node.js 18, 20 or 22. +- Latest version of Node.js 20, 22 or 24. - Windows 10+, Windows Server 2016+ or Windows Subsystem for Linux (WSL). - macOS 14 Ventura, or later. - Debian 12, Ubuntu 22.04, Ubuntu 24.04, on x86-64 and arm64 architecture. diff --git a/nodejs/docs/test-reporters.mdx b/nodejs/docs/test-reporters.mdx index e77c04982fc..fbf782ca202 100644 --- a/nodejs/docs/test-reporters.mdx +++ b/nodejs/docs/test-reporters.mdx @@ -252,6 +252,7 @@ HTML report supports the following configuration options and environment variabl | `PLAYWRIGHT_HTML_HOST` | `host` | When report opens in the browser, it will be served bound to this hostname. | `localhost` | `PLAYWRIGHT_HTML_PORT` | `port` | When report opens in the browser, it will be served on this port. | `9323` or any available port when `9323` is not available. | `PLAYWRIGHT_HTML_ATTACHMENTS_BASE_URL` | `attachmentsBaseURL` | A separate location where attachments from the `data` subdirectory are uploaded. Only needed when you upload report and `data` separately to different locations. | `data/` +| `PLAYWRIGHT_HTML_NO_SNIPPETS` | `noSnippets` | If true, disable rendering code snippets in the action log. If there is a top level error, that report section with code snippet will still render. Supports `true`, `1`, `false`, and `0`. | `false` ### Blob reporter diff --git a/python/docs/chrome-extensions.mdx b/python/docs/chrome-extensions.mdx index 35de29a02cd..6ce0d59914a 100644 --- a/python/docs/chrome-extensions.mdx +++ b/python/docs/chrome-extensions.mdx @@ -13,7 +13,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; Extensions only work in Chrome / Chromium launched with a persistent context. Use custom browser args at your own risk, as some of them may break Playwright functionality. ::: -The snippet below retrieves the [background page](https://developer.chrome.com/extensions/background_pages) of a [Manifest v2](https://developer.chrome.com/docs/extensions/mv2/) extension whose source is located in `./my-extension`. +The snippet below retrieves the [service worker](https://developer.chrome.com/docs/extensions/develop/concepts/service-workers) of a [Manifest v3](https://developer.chrome.com/docs/extensions/develop/migrate) extension whose source is located in `./my-extension`. Note the use of the `chromium` channel that allows to run extensions in headless mode. Alternatively, you can launch the browser in headed mode. @@ -43,12 +43,12 @@ def run(playwright: Playwright): f"--load-extension={path_to_extension}", ], ) - if len(context.background_pages) == 0: - background_page = context.wait_for_event('backgroundpage') + if len(context.service_workers) == 0: + service_worker = context.wait_for_event('serviceworker') else: - background_page = context.background_pages[0] + service_worker = context.service_workers[0] - # Test the background page as you would any other page. + # Test the service worker as you would any other worker. context.close() @@ -77,12 +77,12 @@ async def run(playwright: Playwright): ], ) - if len(context.background_pages) == 0: - background_page = await context.wait_for_event('backgroundpage') + if len(context.service_workers) == 0: + service_worker = await context.wait_for_event('serviceworker') else: - background_page = context.background_pages[0] + service_worker = context.service_workers[0] - # Test the background page as you would any other page. + # Test the service worker as you would any other worker. await context.close() @@ -129,17 +129,12 @@ def context(playwright: Playwright) -> Generator[BrowserContext, None, None]: @pytest.fixture() def extension_id(context) -> Generator[str, None, None]: - # for manifest v2: - # background = context.background_pages[0] - # if not background: - # background = context.wait_for_event("backgroundpage") - # for manifest v3: - background = context.service_workers[0] - if not background: - background = context.wait_for_event("serviceworker") + service_worker = context.service_workers[0] + if not service_worker: + service_worker = context.wait_for_event("serviceworker") - extension_id = background.url.split("/")[2] + extension_id = service_worker.url.split("/")[2] yield extension_id ```