I have a problem with my Puppeteer automation script. When I close the browser and start it again, all the cookies disappear. I need them to stay saved for my next session.
Here’s my current code setup:
const puppeteer = require('puppeteer');
(async () => {
const profilePath = 'D:\\temp_folder\\abc';
const launchOptions = [
...puppeteer.defaultArgs({ headless: false }).map(option => {
if (option.startsWith('--disable-features')) {
return option.replace('Translate,', '').replace(',Translate', '');
}
return option;
}),
'--window-size=1920,1080',
'--disable-sync',
'--no-sandbox',
'--ignore-ssl-errors'
].filter(option => !['--enable-automation', '--disable-extensions'].includes(option));
const chromeInstance = await puppeteer.launch({
args: launchOptions,
acceptInsecureCerts: true,
headless: false,
ignoreHTTPSErrors: true,
defaultViewport: null,
ignoreDefaultArgs: true,
userDataDir: profilePath,
pipe: true
});
const newPage = await chromeInstance.newPage();
// Additional code here
})();
Any suggestions on how to fix this issue?