playwright-localstorage

Extension for the Playwright package
that allows access to the Web Storage API.
Installation
pip install playwright-localstorage
Usage
Synchronous
from playwright.sync_api import Playwright
from playwright.sync_api import sync_playwright
from playwright_localstorage import LocalStorageAccessor
def run(p: Playwright):
chromium = p.chromium
browser = chromium.launch(headless=False)
page = browser.new_page()
page.goto("http://example.com")
accessor = LocalStorageAccessor(page)
accessor.set("token", "secret-token")
token = accessor.get("token")
print(token)
exists = accessor.has("token")
print(exists)
keys = accessor.keys()
print(keys)
items = accessor.items()
print(items)
accessor.remove("token")
exists = accessor.has("token")
print(exists)
browser.close()
with sync_playwright() as playwright:
run(playwright)
Asynchronous
The package supports asynchronous implementation.