Skip to main content

Extension for the Playwright package that allows access to the Web Storage API.

Project description

playwright-localstorage

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")  # Set value
    token = accessor.get("token")          # Get value
    
    print(token)                           # >> "secret-token"
    
    exists = accessor.has("token")         # Check key for existence
    
    print(exists)                          # >> True
    
    keys = accessor.keys()                 # Get all keys
    
    print(keys)                            # >> ["token"]
    
    items = accessor.items()               # Get all items
    
    print(items)                           # >> {"token": "secret-token"}
    
    accessor.remove("token")               # Remove key
    
    exists = accessor.has("token")
    
    print(exists)                          # >> False
    
    browser.close()


with sync_playwright() as playwright:
    run(playwright)

Asynchronous

The package supports asynchronous implementation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playwright_localstorage-1.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playwright_localstorage-1.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file playwright_localstorage-1.0.1.tar.gz.

File metadata

  • Download URL: playwright_localstorage-1.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for playwright_localstorage-1.0.1.tar.gz
Algorithm Hash digest
SHA256 614cb25015b48d6039e719f1ec383ff68c7fedba8d05fd507a681bb7d629a959
MD5 93401fc97db309448576808dc6c6dd77
BLAKE2b-256 9467028e56b0ebc3350f5301f74d5aa39b9aa30670551ba7ea4d98642931440f

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_localstorage-1.0.1.tar.gz:

Publisher: release.yml on swimmwatch/playwright-localstorage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file playwright_localstorage-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_localstorage-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12f717f7655ad1f7011f16097463fb8fe217793752200789a4fdaeedf9f62011
MD5 5e5be014b6e04f961de3f85c8096e0c1
BLAKE2b-256 dff2ce81e24fbb267fc066b3b7f8a4fba3d55f86ad9c0d5177f288f1b4212305

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_localstorage-1.0.1-py3-none-any.whl:

Publisher: release.yml on swimmwatch/playwright-localstorage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page