[BUG] Does browserContext.addCookie only work with DEFAULT profile directory?
When I add cookies into the browserContext created by launchPersistentContext addCookies works only for profile with directory DEFAULT and not working for other profile directories
let browserContext = await chromium.launchPersistentContext('user-data-dir', {
headless: false,
args: [
"--timeout=100 * 1000",
"--disable-site-isolation-trials",
"--disable-web-security",
"--disable-cross-origin",
"--profile-directory=" + "DEFAULT"
],
ignoreDefaultArgs: [
"--headless",
"--enable-automation",
'--allow-running-insecure-content'
],
});
const jsonString = fs.readFileSync('auth.json');
let auth = JSON.parse(jsonString);
await browserContext.addCookies(auth.cookies) // works only if profile directory is DEFAULT
let page = await browserContext.newPage();
Can you elaborate on your use case? Once you pass custom CLI args to the browsers, there is risk of things not working perfectly.
@rwoll I am trying to use my gmail login cookies into the session .But I am unable to do that since addCookies not loading if profile directory is not DEFAULT.It should either work for all profile directories or shouldnt work at all. Its strange behaviour to work only for DEFAULT profile.
@Gokulnath31 The --profile-directory flag might not work perfectly with playwright API's right now. Sorry for the inconvenience!