How can I use Puppeteer to interact with a Chrome extension in my tests? or Best way to interact with

18 Replies, 1344 Views

Hey! I struggled with this too. The key is loading the extension AND opening its background page.

Here’s a quick snippet:
```javascript
const extensionPath = '/path/to/extension';
const browser = await puppeteer.launch({
args: [`--disable-extensions-except=${extensionPath}`, `--load-extension=${extensionPath}`]
});

// Access the background page
const backgroundPage = await browser.backgroundPages()[0];
```
Without the background page, you can’t really puppeteer interact with extension properly. Hope this helps!

Messages In This Thread



Users browsing this thread: 1 Guest(s)