# playwright-localstorage
<!-- markdownlint-disable -->
![playwright-localstorage](https://socialify.git.ci/swimmwatch/playwright-localstorage/image?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Brick%20Wall&theme=Dark)
<div align="center">
<p>
<a href="https://pypi.org/project/playwright-localstorage">
<img src="https://img.shields.io/pypi/v/playwright-localstorage.svg" alt="PyPI">
</a>
<a href="pyproject.toml">
<img src="https://img.shields.io/pypi/pyversions/playwright-localstorage" alt="Supported Python Versions">
</a>
<br/>
<a href="LICENSE">
<img src="https://img.shields.io/github/license/swimmwatch/playwright-localstorage" alt="License">
</a>
<a href="https://github.com/ambv/black">
<img src="https://img.shields.io/badge/code%20style-black-black" alt="Code style">
</a>
<a href="https://github.com/pycqa/flake8">
<img src="https://img.shields.io/badge/lint-flake8-black" alt="Linter">
</a>
<a href="https://github.com/python/mypy">
<img src="https://img.shields.io/badge/type%20checker-mypy-black" alt="Type checker">
</a>
<a href="https://snyk.io/advisor/python/playwright-localstorage">
<img src="https://snyk.io/advisor/python/playwright-localstorage/badge.svg" alt="Package health">
</a>
<br/>
<a href="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/python-check.yml">
<img src="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/python-check.yml/badge.svg" alt="Tests">
</a>
<a href="https://codecov.io/github/swimmwatch/playwright-localstorage" target="_blank">
<img src="https://codecov.io/github/swimmwatch/playwright-localstorage/branch/dev/graph/badge.svg?token=CHNJDD5OY0" alt="Coverage">
</a>
<a href="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/release.yml">
<img src="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/release.yml/badge.svg" alt="Release">
</a>
<a href="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/docs.yml">
<img src="https://github.com/swimmwatch/playwright-localstorage/actions/workflows/docs.yml/badge.svg" alt="Docs">
</a>
</p>
</div>
<!-- markdownlint-enable -->
Extension for the Playwright package
that allows access to the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).
## Installation
```shell
pip install playwright-localstorage
```
## Usage
### Synchronous
```python
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.
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/playwright-localstorage/",
"name": "playwright-localstorage",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "Playwright, Web Storage API, Poetry",
"author": "Dmitry Vasiliev",
"author_email": "contact.vasiliev.dmitry@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/58/17/3ff07b363912014fe2802c5c87f7b3c7b8ff16225480d28e04fdeade09b5/playwright_localstorage-1.1.0.tar.gz",
"platform": null,
"description": "# playwright-localstorage\n\n<!-- markdownlint-disable -->\n![playwright-localstorage](https://socialify.git.ci/swimmwatch/playwright-localstorage/image?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Brick%20Wall&theme=Dark)\n\n<div align=\"center\">\n <p>\n <a href=\"https://pypi.org/project/playwright-localstorage\">\n <img src=\"https://img.shields.io/pypi/v/playwright-localstorage.svg\" alt=\"PyPI\">\n </a>\n <a href=\"pyproject.toml\">\n <img src=\"https://img.shields.io/pypi/pyversions/playwright-localstorage\" alt=\"Supported Python Versions\">\n </a>\n <br/>\n <a href=\"LICENSE\">\n <img src=\"https://img.shields.io/github/license/swimmwatch/playwright-localstorage\" alt=\"License\">\n </a>\n <a href=\"https://github.com/ambv/black\">\n <img src=\"https://img.shields.io/badge/code%20style-black-black\" alt=\"Code style\">\n </a>\n <a href=\"https://github.com/pycqa/flake8\">\n <img src=\"https://img.shields.io/badge/lint-flake8-black\" alt=\"Linter\">\n </a>\n <a href=\"https://github.com/python/mypy\">\n <img src=\"https://img.shields.io/badge/type%20checker-mypy-black\" alt=\"Type checker\">\n </a>\n <a href=\"https://snyk.io/advisor/python/playwright-localstorage\">\n <img src=\"https://snyk.io/advisor/python/playwright-localstorage/badge.svg\" alt=\"Package health\">\n </a>\n <br/>\n <a href=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/python-check.yml\">\n <img src=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/python-check.yml/badge.svg\" alt=\"Tests\">\n </a>\n <a href=\"https://codecov.io/github/swimmwatch/playwright-localstorage\" target=\"_blank\">\n <img src=\"https://codecov.io/github/swimmwatch/playwright-localstorage/branch/dev/graph/badge.svg?token=CHNJDD5OY0\" alt=\"Coverage\">\n </a>\n <a href=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/release.yml\">\n <img src=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/release.yml/badge.svg\" alt=\"Release\">\n </a>\n <a href=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/docs.yml\">\n <img src=\"https://github.com/swimmwatch/playwright-localstorage/actions/workflows/docs.yml/badge.svg\" alt=\"Docs\">\n </a>\n </p>\n</div>\n<!-- markdownlint-enable -->\n\nExtension for the Playwright package \nthat allows access to the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).\n\n## Installation\n\n```shell\npip install playwright-localstorage\n```\n\n## Usage\n\n### Synchronous\n\n```python\nfrom playwright.sync_api import Playwright\nfrom playwright.sync_api import sync_playwright\n\nfrom playwright_localstorage import LocalStorageAccessor\n\n\ndef run(p: Playwright):\n chromium = p.chromium\n browser = chromium.launch(headless=False)\n \n page = browser.new_page()\n page.goto(\"http://example.com\")\n \n accessor = LocalStorageAccessor(page)\n \n accessor.set(\"token\", \"secret-token\") # Set value\n token = accessor.get(\"token\") # Get value\n \n print(token) # >> \"secret-token\"\n \n exists = accessor.has(\"token\") # Check key for existence\n \n print(exists) # >> True\n \n keys = accessor.keys() # Get all keys\n \n print(keys) # >> [\"token\"]\n \n items = accessor.items() # Get all items\n \n print(items) # >> {\"token\": \"secret-token\"}\n \n accessor.remove(\"token\") # Remove key\n \n exists = accessor.has(\"token\")\n \n print(exists) # >> False\n \n browser.close()\n\n\nwith sync_playwright() as playwright:\n run(playwright)\n\n```\n\n### Asynchronous\n\nThe package supports asynchronous implementation.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Extension for the Playwright package that allows access to the Web Storage API.",
"version": "1.1.0",
"project_urls": {
"Documentation": "https://github.com/swimmwatch/playwright-localstorage",
"Homepage": "https://pypi.org/project/playwright-localstorage/",
"Repository": "https://github.com/swimmwatch/playwright-localstorage"
},
"split_keywords": [
"playwright",
" web storage api",
" poetry"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "58f2187e2539c74b4c347d2bacbb64d87ae74142d32e5517828b84a99b68dfc4",
"md5": "2174e81d8ec879e0f1a05e2c472cf420",
"sha256": "3951bbee63230d6d9f85c04d927b710ba0bdc2d59b0cb20376e316e1e049475e"
},
"downloads": -1,
"filename": "playwright_localstorage-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2174e81d8ec879e0f1a05e2c472cf420",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5972,
"upload_time": "2025-01-03T12:24:05",
"upload_time_iso_8601": "2025-01-03T12:24:05.101104Z",
"url": "https://files.pythonhosted.org/packages/58/f2/187e2539c74b4c347d2bacbb64d87ae74142d32e5517828b84a99b68dfc4/playwright_localstorage-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "58173ff07b363912014fe2802c5c87f7b3c7b8ff16225480d28e04fdeade09b5",
"md5": "6826c380c77ad372eb65c15fc3efbfa0",
"sha256": "4159805712dd6576870ae5cf66b16435a10998544548abd1b8b74a452e69e187"
},
"downloads": -1,
"filename": "playwright_localstorage-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6826c380c77ad372eb65c15fc3efbfa0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 4491,
"upload_time": "2025-01-03T12:24:08",
"upload_time_iso_8601": "2025-01-03T12:24:08.038554Z",
"url": "https://files.pythonhosted.org/packages/58/17/3ff07b363912014fe2802c5c87f7b3c7b8ff16225480d28e04fdeade09b5/playwright_localstorage-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-03 12:24:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "swimmwatch",
"github_project": "playwright-localstorage",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "playwright-localstorage"
}