An open API service indexing awesome lists of open source software.

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.

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