I’m trying to find a way in puppeteer to open multiple instance with different Chrome profiles (to have different cookies in the same website), I found the way to do it but I’d like to do it in a for loop.
The way I’m doing its the next
const browser1 = await puppeteer.launch({
headless: false,
executablePath: 'C:\Program Files\Google\Chrome\Application\chrome.exe',
args: ["--user-data-dir=C:/Users/Nico/AppData/Local/Google/Chrome/User Data/Profile 1"]
});
const page1 = await browser1.newPage();
await page1.goto("http://www.website.com");
const browser2 = await puppeteer.launch({
headless: false,
executablePath: 'C:\Program Files\Google\Chrome\Application\chrome.exe',
args: ["--user-data-dir=C:/Users/Nico/AppData/Local/Google/Chrome/User Data/Profile 2"]
});
const page2 = await browser2.newPage();
await page2.goto("http://www.website.com");
So I’d like to find a way to do it in a for loop so I don’t have to make each browser[i] in the code
I tried with
for (let i = 2; i < 20; i++) {
const browser[i] = await puppeteer.launch({
headless: false,
executablePath: 'C:\Program Files\Google\Chrome\Application\chrome.exe',
args: ["--user-data-dir=C:/Users/Nico/AppData/Local/Google/Chrome/User Data/Profile ", [i]]
});
}
But doesn’t seems to work