Skip to main content

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.

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.1.0.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.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: playwright_localstorage-1.1.0.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.1.0.tar.gz
Algorithm Hash digest
SHA256 4159805712dd6576870ae5cf66b16435a10998544548abd1b8b74a452e69e187
MD5 6826c380c77ad372eb65c15fc3efbfa0
BLAKE2b-256 58173ff07b363912014fe2802c5c87f7b3c7b8ff16225480d28e04fdeade09b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_localstorage-1.1.0.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_localstorage-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3951bbee63230d6d9f85c04d927b710ba0bdc2d59b0cb20376e316e1e049475e
MD5 2174e81d8ec879e0f1a05e2c472cf420
BLAKE2b-256 58f2187e2539c74b4c347d2bacbb64d87ae74142d32e5517828b84a99b68dfc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwright_localstorage-1.1.0-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.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.1

2 files

Supported by

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