mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
990635abc9
🤖 I have created a release *beep* *boop* --- <details><summary>puppeteer: 19.2.1</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * puppeteer-core bumped from 19.2.0 to ^19.2.1 </details> <details><summary>puppeteer-core: 19.2.1</summary> ## [19.2.1](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v19.2.0...puppeteer-core-v19.2.1) (2022-10-28) ### Bug Fixes * resolve navigation requests when request fails ([#9178](https://github.com/puppeteer/puppeteer/issues/9178)) ([c11297b
](c11297baa5
)), closes [#9175](https://github.com/puppeteer/puppeteer/issues/9175) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
1.2 KiB
1.2 KiB
Chrome Extensions
Puppeteer can be used for testing Chrome Extensions.
:::caution
Extensions in Chrome/Chromium currently only work in non-headless mode and experimental Chrome headless mode.
:::
The following is code for getting a handle to the
background page of
an extension whose source is located in ./my-extension
:
const puppeteer = require('puppeteer');
(async () => {
const pathToExtension = require('path').join(__dirname, 'my-extension');
const browser = await puppeteer.launch({
headless: 'chrome',
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
});
const backgroundPageTarget = await browser.waitForTarget(
target => target.type() === 'background_page'
);
const backgroundPage = await backgroundPageTarget.page();
// Test the background page as you would any other page.
await browser.close();
})();
:::note
Chrome Manifest V3 extensions have a background ServiceWorker of type 'service_worker', instead of a page of type 'background_page'.
:::
:::note
It is not yet possible to test extension popups or content scripts.
:::