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().
java
page.navigate("https://example.com");
page.localStorage().setItem("token", "abc");
String token = page.localStorage().getItem("token");
List<WebStorageItem> all = page.localStorage().items();
page.localStorage().removeItem("token");
page.localStorage().clear();Methods
webStorage.clear()
Added in: v1.61Removes all items from the storage.
webStorage.getItem()
Added in: v1.61Returns the value for the given name if present.
Arguments
Returns
null | string
webStorage.items()
Added in: v1.61Returns all items in the storage as name/value pairs.
Returns
Array<Object>
webStorage.removeItem()
Added in: v1.61Removes the item with the given name. No-op if the item is absent.
Arguments
webStorage.setItem()
Added in: v1.61Sets the value for the given name. Overwrites any existing value for that name.
Arguments