I am trying to create a new browserContext in a headless Chrome by issuing raw CDP commands. Looking at the documentation of the CDP Protocol it seems straightforward enough: issue a Target.createBrowserContext
command. When I issue the command I get the following error:
{"id":2,"error":{"code":-32000,"message":"Not allowed"}}
I’ve tried to see how Puppeteer does it by logging the messages it sends on different commands. When using browser.createBrowserContext()
a new context is created successfully. When trying the same thing manually a few lines below, the call fails.
Some sample code to reproduce:
const puppeteer = require('puppeteer');
(async ()=>{
console.log("STARTING BROWSER");
const browser = await puppeteer.launch({args:["--remote-allow-origins=*"]});
console.log("STARTING CONTEXT");
const context = await browser.createBrowserContext();
const page = await context.newPage();
const cdp = await page.createCDPSession();
await cdp.send("Target.createBrowserContext");
})();
Alexandru Postolache is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.