[Feature] Browser context serialization to support local storage
See original GitHub issueThe browserContext.cookies
and browserContext.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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:6 (4 by maintainers)
We built a
saveState
andsetState
in playwright-utils for cookies, localStorage, sessionStorage, not indexed db yetWe 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 😃