Skip to main content

A browserless HTML testing library for Python

Project description

unbrowsed

A browserless HTML testing library for Python, inspired by testing-library.

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
  • Query functions that encourage accessible testing practices

Installation

pip install unbrowsed

Usage

Basic Example

from unbrowsed import parse_html, query_by_label_text

# Parse HTML content
html = """
<form>
    <label for="username">Username</label>
    <input id="username" type="text">
    <label for="password">Password</label>
    <input id="password" type="password">
    <button type="submit">Login</button>
</form>
"""
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

# 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

pytest

Releasing a New Version

To release a new version:

  1. Update the version in pyproject.toml
  2. Create and push a new tag:
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

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

unbrowsed-0.1.0a22.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

unbrowsed-0.1.0a22-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file unbrowsed-0.1.0a22.tar.gz.

File metadata

  • Download URL: unbrowsed-0.1.0a22.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unbrowsed-0.1.0a22.tar.gz
Algorithm Hash digest
SHA256 fb33414941f7f14e48e83b60979e94ef83f4addb8c6e06f81166ee0015afae84
MD5 37b6cda63f3f490c0a8eaa346b09d619
BLAKE2b-256 ae83843b7b7d2f329c5d6e83daf0bd5b6ccd2de151709609f01881873e242eb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for unbrowsed-0.1.0a22.tar.gz:

Publisher: test.yml on valentinogagliardi/unbrowsed

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

File details

Details for the file unbrowsed-0.1.0a22-py3-none-any.whl.

File metadata

  • Download URL: unbrowsed-0.1.0a22-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unbrowsed-0.1.0a22-py3-none-any.whl
Algorithm Hash digest
SHA256 ce8f4d78010d545b459010143323a33e63e07f9016ad4166057f05c2a3a49948
MD5 fe7e9b0a3815dc796399a520f5ee156f
BLAKE2b-256 03c0cc1a2390803d3f6e9521ca2e4b032e947c3be6d14330293b3a102d7b6bf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for unbrowsed-0.1.0a22-py3-none-any.whl:

Publisher: test.yml on valentinogagliardi/unbrowsed

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