I keep getting the same error no matter what, when Puppeteer launches Chrome:
My code:
//....
let pathToExtension = require('path').join(__dirname, 'ext'); // doesn't help
// pathToExtension = none of these work either: the app directory, the chrome extension directory, the chrome user data directory ...
pathToExtension = `E:/ext`
browser = await puppeteer.launch({
headless: false, //true,
executablePath: executablePath,
args: [`--disable-extensions-except=${pathToExtension}'`,
`--load-extension=${pathToExtension}`,
// ignoredDefaultArgs: ['--disable-extensions'],
// I would expect the above to allow all extensions, but seems to do nothing
})
//....
I have followed existing solutions here on SO:
- Extension must be unpacked:
Failed to load extension and manifest file is missing or unreadable while trying to test Chrome extensions with Playwright - Both
--disable-extensions-except
and--load-extension
need to be set:
puppeteer unable to load chrome extension in browser
Also, my code above is basically one from official docs https://pptr.dev/guides/chrome-extensions/ .
UPDATE:
Switching headless: false
to true
made the error (hopefully not just the message) disappear. However, I still need the extensions to load on headful Chrome.
The doc page (above) states that "Extensions in Chrome/Chromium currently only work in non-headless mode and experimental Chrome headless mode.", so I'd expect it to work in headful/non-headless. Not sure abut the "experimental Chrome".