-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Browser context serialization to support local storage #1129
Comments
We built a |
I would use this to save the state so that I don't need to redo the steps for login and some other authentication |
We now have a guide for sharing authentication state across browser contexts (using APIs for cookies and local storage). We could evolve this into a unified API for all "browser context state" based on user feedback. Please share your user scenarios and help us identify what's missing :) |
This is now implemented via https://playwright.dev/#version=master&path=docs%2Fapi.md&q=browsernewpageoptions--options-storagestate |
@pavelfeldman Can we please get sessionStorage included in this? It seems odd that it wouldn't be considered part of the storage state, even if it is less frequently used. I understand we can write it quite easily, as in the documentation but I feel like it belongs. |
@joshpzero can you file a separate feature request for this? There are some questions like what to do if there are two pages from the same origin in the same context that have different sessionStorage states and whether sessionStorage for the current origin in the page is sufficient or you may need previous states too, otherwise it's doable. Having |
The
browserContext.cookies
andbrowserContext.setCookies
methods make it possible for users to serialize cookies and load them into a new context. This enables loading a new context with authentication state before running tests.Some apps use local storage to maintain their authentication state, and we should have similar methods for local storage.
Additionally, it might be worth evaluating whether we want to create a higher-level abstraction ("browser context state" maybe?) that covers all such storage (cookies, local storage, indexed db, etc). That way, users will not need to know which storage type they want to serialize and load over. In many cases, users are building applications where authentication is third-party (SSO etc) and therefore knowing which state type is used by auth is not possible.
The text was updated successfully, but these errors were encountered: