Class: Playwright::WebStorage
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::WebStorage
- Defined in:
- lib/playwright_api/web_storage.rb,
sig/playwright.rbs
Overview
WebStorage exposes the page's localStorage or sessionStorage for the current origin via an async,
browser-consistent API.
Instances are accessed through [property: Page.localStorage] and [property: Page.sessionStorage].
page.goto("https://example.com")
page.local_storage.set_item("token", "abc")
token = page.local_storage.get_item("token")
all = page.local_storage.items()
page.local_storage.remove_item("token")
page.local_storage.clear()
Instance Method Summary collapse
-
#clear ⇒ void
Removes all items from the storage.
-
#get_item(name) ⇒ nil, String
Returns the value for the given
nameif present. -
#items ⇒ Array[untyped]
Returns all items in the storage as name/value pairs.
-
#remove_item(name) ⇒ void
Removes the item with the given
name. -
#set_item(name, value) ⇒ void
Sets the value for the given
name.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#clear ⇒ void
This method returns an undefined value.
Removes all items from the storage.
44 45 46 |
# File 'lib/playwright_api/web_storage.rb', line 44 def clear wrap_impl(@impl.clear) end |
#get_item(name) ⇒ nil, String
Returns the value for the given name if present.
26 27 28 |
# File 'lib/playwright_api/web_storage.rb', line 26 def get_item(name) wrap_impl(@impl.get_item(unwrap_impl(name))) end |
#items ⇒ Array[untyped]
Returns all items in the storage as name/value pairs.
20 21 22 |
# File 'lib/playwright_api/web_storage.rb', line 20 def items wrap_impl(@impl.items) end |
#remove_item(name) ⇒ void
This method returns an undefined value.
Removes the item with the given name. No-op if the item is absent.
38 39 40 |
# File 'lib/playwright_api/web_storage.rb', line 38 def remove_item(name) wrap_impl(@impl.remove_item(unwrap_impl(name))) end |
#set_item(name, value) ⇒ void
This method returns an undefined value.
Sets the value for the given name. Overwrites any existing value for that name.
32 33 34 |
# File 'lib/playwright_api/web_storage.rb', line 32 def set_item(name, value) wrap_impl(@impl.set_item(unwrap_impl(name), unwrap_impl(value))) end |