Skip to content

UI.LocalStorage.get()

Returns the value of an item stored in the browser’s local storage for the current page.

Local storage is scoped to the origin of the current page (protocol, domain, and port).

Usage

js
UI.LocalStorage.get(key: string)

Parameters

ParameterTypeDescription
keystringThe key of the local storage item to retrieve

Returns

Returns the stored value as a string or a parsed object if the value is valid JSON, or null if the item does not exist.

Example

js
I.click("Add to cart")

var cart = UI.LocalStorage.get("cart")

TEST.log.info("# of items in cart: " + cart.items.length)

In this example, the test retrieves the value of cart from the local storage.