puppeteer
puppeteer copied to clipboard
[Bug]: 'Unable to capture screenshot' if external extension is used
Bug description
I am observing unstable screenshot behaviour. On a specific website, screenshot function fails with 'Unable to capture screenshot' error. I am running in headful mode, because I also want to use an extension to block the cooies message. This is the copy paste code to reproduce the error.
const puppeteer = require('puppeteer');
(async ()=>{
const pathToExtension = require('path').join(__dirname, 'I_dont_care_about_cookies'); // available here: https://chrome.google.com/webstore/detail/i-dont-care-about-cookies/fihnjjcciajhdojfnbdddfaoknhalnja?hl=en
let desktopPath = "./vanilla-desktop.jpg";
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
args: [
'--disable-setuid-sandbox',
'--no-sandbox',
'--window-size=1920,1080',
'--disable-dev-shm-usage',
'--shm-size=3gb',
'--disable-extensions-except=${pathToExtension}',
'--load-extension=${pathToExtension}',
]
});
let page = await browser.newPage();
let response = await page.goto("https://www.sinsay.com/si/sl/sale/woman/view-all-clothes", { waitUntil: "networkidle2" }); //this fails
//let response = await page.goto("https://www.stackoverflow.com", { waitUntil: "networkidle2" }); //this works fine
await page.waitForTimeout(6000);
await page.setViewport({ width: 1920, height: 1080 });
await page.evaluate(() => window.scrollTo(0, 0));
await page.screenshot({ path: desktopPath, fullPage: true });
await browser.close()
})();
Puppeteer version
15.3.2
Node.js version
v16.15.0
npm version
8.5.5
What operating system are you seeing the problem on?
macOS
Relevant log output
/path/to/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:278
error: new Errors_js_1.ProtocolError(),
^
ProtocolError: Protocol error (Page.captureScreenshot): Unable to capture screenshot
at /path/to/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:278:24
at new Promise (<anonymous>)
at CDPSession.send (/path/to/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:274:16)
at Page._Page_screenshotTask (/path/to/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2574:74)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
originalMessage: 'Unable to capture screenshot'
}
Does it reproduce without the extension?
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!