WebStorage
Added in: v1.61WebStorage 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.
csharp
await page.GotoAsync("https://example.com");
await page.LocalStorage.SetItemAsync("token", "abc");
var token = await page.LocalStorage.GetItemAsync("token");
var all = await page.LocalStorage.ItemsAsync();
await page.LocalStorage.RemoveItemAsync("token");
await page.LocalStorage.ClearAsync();Methods
WebStorage.ClearAsync()
Added in: v1.61Removes all items from the storage.
WebStorage.GetItemAsync()
Added in: v1.61Returns the value for the given name if present.
Arguments
Returns
null | string
WebStorage.ItemsAsync()
Added in: v1.61Returns all items in the storage as name/value pairs.
Returns
Array<Object>
WebStorage.RemoveItemAsync()
Added in: v1.61Removes the item with the given name. No-op if the item is absent.
Arguments
WebStorage.SetItemAsync()
Added in: v1.61Sets the value for the given name. Overwrites any existing value for that name.
Arguments