so am trying to launch puppeteer with already existed chrome profile and it works , but what i want to do is to launch the same process multiple time which throw an error
(node:12820) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! [0311/152606.490:ERROR:chrome_main_delegate(679)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value
am doing it in this way :
const browser = await puppeteer.launch({
executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
headless: false,
// excludeSwitches: 'enable-automation',
args: [
'--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
],
});
so am trying to launch puppeteer with already existed chrome profile and it works , but what i want to do is to launch the same process multiple time which throw an error
(node:12820) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! [0311/152606.490:ERROR:chrome_main_delegate(679)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value
am doing it in this way :
const browser = await puppeteer.launch({
executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
headless: false,
// excludeSwitches: 'enable-automation',
args: [
'--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
],
});
Share
Improve this question
asked Mar 11, 2021 at 13:33
DUMBUSERDUMBUSER
5518 silver badges25 bronze badges
0
1 Answer
Reset to default 6 +50As far as I can tell Puppeteer doesn't allow itself to be launched more than once for the same userDataDir because that folder includes a caching folder which must be unique per puppeteer instance. You can however open multiple pages using the same browser instance. For example:
const browser = await puppeteer.launch({
executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
headless: false,
// excludeSwitches: 'enable-automation',
args: [
'--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
],
});
const page1 = await browser.newPage();
const page2 = await browser.newPage();
await page1.goto("https://www.bbc.co.uk", {waitUntil: 'networkidle2'});
await page2.goto("https://www.google.co.uk", {waitUntil: 'networkidle2'});
If you truly need pletely isolated Puppeteer processes you'll need to launch each with its own unique userDataDir. You could try building a lightweight profile with just the config files you need and making a copy for each process you launch.
Sorry, that this isn't really a perfect solution but I don't think what you're trying to do is possible.