https://github.com/valentinogagliardi/unbrowsed
A browserless HTML testing library for Python.
https://github.com/valentinogagliardi/unbrowsed
a11y a11y-testing dom dom-testing html5 python python-html python-testing testing-library testing-tools
Last synced: 2 months ago
JSON representation
A browserless HTML testing library for Python.
- Host: GitHub
- URL: https://github.com/valentinogagliardi/unbrowsed
- Owner: valentinogagliardi
- License: mit
- Created: 2025-03-05T11:07:05.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-03-20T21:02:19.000Z (3 months ago)
- Last Synced: 2025-04-10T07:51:36.605Z (3 months ago)
- Topics: a11y, a11y-testing, dom, dom-testing, html5, python, python-html, python-testing, testing-library, testing-tools
- Language: Python
- Homepage: https://unbrowsed.readthedocs.io/
- Size: 128 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.rst
- License: LICENSE
Awesome Lists containing this project
README
# unbrowsed
A browserless HTML testing library for Python, inspired by [testing-library](https://testing-library.com/).
## Overview
unbrowsed allows you to test HTML without spawning a browser. It provides a simple, intuitive API for querying HTML elements similar to testing-library's approach, encouraging accessible and maintainable tests.
## Features
- Fast HTML parsing with [selectolax](https://github.com/rushter/selectolax)
- Query functions that encourage accessible testing practices## Installation
```bash
pip install unbrowsed
```## Usage
### Basic Example
```python
from unbrowsed import parse_html, query_by_label_text# Parse HTML content
html = """Username
Password
Login"""
dom = parse_html(html)# Query elements by label text
username_input = query_by_label_text(dom, "Username")
assert username_input is not None
```## Development
### Setup
```bash
# Clone the repository
git clone https://github.com/username/unbrowsed.git
cd unbrowsed# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate# Install development dependencies
pip install -e ".[test]"
```### Running Tests
```bash
pytest
```### Releasing a New Version
To release a new version:
1. Update the version in `pyproject.toml`
2. Create and push a new tag:```bash
git tag 0.1.0
git push origin 0.1.0
```This will trigger the CI pipeline to build and publish the package to PyPI automatically.
## License
MIT