microsoft / microsoft/playwright

[Feature]: support sessionStorage option for storageState persistence & restoration

Open
#31,108 7 comments 25 reactions 0 assignees View on GitHub
P3-collecting-feedback
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

### 🚀 Feature Request

[`storageState` | TestOptions | Playwright](https://playwright.dev/docs/api/class-testoptions#test-options-storage-state) is very convenient. I appreciate that [Session storage | Authentication | Playwright](https://playwright.dev/docs/auth#session-storage) outlines how to also persist and restore `sessionStorage` but it would be even more convenient to have a built-in option.

### Example

```ts
await page.context().storageState({ path: authFile, includeSessionStorage: true });
```

or, if richer control is desired:

```ts
await page.context().storageState({
path: authFile,
origins: {
"http://localhost:3000": ["localStorage", "sessionStorage"],
"https://example.com": ["sessionStorage"],
"https://www.iana.org": [],
"*": ["localStorage"]
},
});
```

### Motivation

Needing to write the extra code for interacting with the filesystem, stringifying and parsing JSON, adding the init script, etc. isn't too terrible but storing an access token in `sessionStorage` seems common enough to support out-of-the-box.

Contributor guide

Open the contributing guide

Research direction

Start with the storageState TestOptions API and the session-storage Authentication documentation linked in the issue. Trace the storageState entry point and determine how sessionStorage persistence and restoration should fit the proposed option shapes. Done means a settled API design, implementation, documentation, and coverage for saving and restoring sessionStorage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.