Typed helper for a single Web Storage area (localStorage or sessionStorage).
Wraps the Playwright 1.61+ storage area API with convenience methods for reading, writing, seeding bulk data, and introspecting the current state.
webStorage.helper
await webStorage.localStorage.seed({ token: 'abc', userId: '42' });const token = await webStorage.localStorage.getItem('token'); Copy
await webStorage.localStorage.seed({ token: 'abc', userId: '42' });const token = await webStorage.localStorage.getItem('token');
Removes all entries from the storage area.
Promise that resolves once the area is cleared.
await webStorage.sessionStorage.clear(); Copy
await webStorage.sessionStorage.clear();
Retrieves the value for a key, or null if the key does not exist.
null
Storage key to look up.
Promise resolving to the stored string value or null.
const lang = await webStorage.localStorage.getItem('lang'); Copy
const lang = await webStorage.localStorage.getItem('lang');
Returns all current entries as a Record<string, string>.
Record<string, string>
Promise resolving to a plain object mapping all keys to their values.
const all = await webStorage.localStorage.items();console.log(all['theme']); // 'dark' Copy
const all = await webStorage.localStorage.items();console.log(all['theme']); // 'dark'
Removes a single key from the storage area.
Storage key to remove.
Promise that resolves once the key is removed.
await webStorage.localStorage.removeItem('tempFlag'); Copy
await webStorage.localStorage.removeItem('tempFlag');
Seeds multiple entries at once, equivalent to calling setItem for each pair.
setItem
Key-value pairs to seed into storage.
Promise that resolves once all items are stored.
await webStorage.localStorage.seed({ theme: 'dark', lang: 'en', userId: '42' }); Copy
await webStorage.localStorage.seed({ theme: 'dark', lang: 'en', userId: '42' });
Sets a single key-value pair in the storage area.
Storage key.
Storage value (string).
Promise that resolves once the item is stored.
await webStorage.localStorage.setItem('theme', 'dark'); Copy
await webStorage.localStorage.setItem('theme', 'dark');
Returns the number of entries currently in the storage area.
Promise resolving to the entry count.
const count = await webStorage.localStorage.size(); Copy
const count = await webStorage.localStorage.size();
Typed helper for a single Web Storage area (localStorage or sessionStorage).
Remarks
Wraps the Playwright 1.61+ storage area API with convenience methods for reading, writing, seeding bulk data, and introspecting the current state.
Capability
webStorage.helper
Example