English · Node.js
Appearance
English · Node.js
Appearance
WebStorage exposes the page's localStorage or sessionStorage for the current origin via an async, browser-consistent API.
Instances are accessed through page.localStorage and page.sessionStorage.
await page.goto('https://example.com');
await page.localStorage.setItem('token', 'abc');
const token = await page.localStorage.getItem('token');
const all = await page.localStorage.items();
await page.localStorage.removeItem('token');
await page.localStorage.clear();Removes all items from the storage.
Returns the value for the given name if present.
Arguments
Returns
Promise<null | string>Returns all items in the storage as name/value pairs.
Returns
Promise<Array<Object>>Removes the item with the given name. No-op if the item is absent.
Arguments
Sets the value for the given name. Overwrites any existing value for that name.
Arguments