sincecutoff.com
← all changes

Playwright page.localStorage and page.sessionStorage read and write origin storage

Introduced 2026-06-15 · score 0.99

HOW TO USE IT

When testing storage for a page’s current origin, use `page.localStorage` or `page.sessionStorage` to set, retrieve, or list items. Navigate the page to the target origin first.

await page.goto('<origin-url>'); await page.localStorage.setItem('token', 'abc'); const token = await page.localStorage.getItem('token'); const items = await page.sessionStorage.items();

WHY THIS HELPS

Set up or inspect browser storage while testing a page for its current origin.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.61.0
  • name (required): Storage item name for `getItem` and `setItem`.
  • value (required): New string value for `setItem`; overwrites the existing value for that name.
  • Prerequisite: Use Playwright v1.61 or later; these WebStorage methods were added in v1.61. Navigate the page to the target origin before accessing its storage.
  • Applies to the page's storage for the current origin.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card