Hi All!
I'm trying to figure out why context.cookies can't find some cookies I've created with context.addcookies.
They're created with these properties: {name: somename, value: somevalue, domain: somedomain} & context.cookies(url) is used to find them. It finds all the other cookies stored in the storagestate json file but not these ones.
A couple of questions
Any help or advice is appreciated as always! ๐
This thread is trying to answer question "Why can't context.cookies find some cookies created with context.addcookies?"
Hey ๐ ,
I'm not 100% positive but when i use storageState
storageState: 'storage-state.json',
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'retain-on-failure',
},
In my playwright.config.js
it does load and shows in the browser(How i get around logging in every time).
A possible source of confusion is that each test runs with its own isolated browser context, so the cookies won't carry over to the next test, unless they are in the storage state. This is all assuming that you are using the page or context fixture like the typical @playwright/test samples from the web site.
๐ I did wonder whether it was using the wrong context or pointing at the wrong users storage state file. It did seem to give the correct cookies for that user though. In the test should it need a test.use({storagestate: etc}) for the logged in user or the user to retrieve cookies for, or both? Can it even do both?
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].