Hi! I saw this commands exists for loading a local storage into a json await page.context().storageState({ path: authFile }); is there a way to load a json into local storage (globally, on every page visited, even before navigating to it)? something like: await page.context().loadIntoLocalStorage({ "demo": "json" }); I'm using Playwright to Node.js
This thread is trying to answer question "Is there a way to load a JSON into local storage globally on every page visited, even before navigating to it, using Playwright for Node.js?"
Can look into: https://github.com/microsoft/playwright/issues/16094
When you create a new browser context, you can pass the storage state (cookies + local storage) as one of the options: https://playwright.dev/docs/api/class-browser#browser-new-context-option-storage-state
If a browser context is opened, you can save/retrieve the storage state using: https://playwright.dev/docs/api/class-browsercontext#browser-context-storage-state
And here's a guide how to use storageState with the @playwright/test runner: https://playwright.dev/docs/auth
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].