Skip to main content

pytest-playwright-softassert

A complete soft-assertion layer over Playwright's native expect() API.

Design

soft_expect(target, message) is a direct, thin wrapper around Playwright's own expect.soft(target, message). It returns Playwright's native LocatorAssertions, PageAssertions, or APIResponseAssertions object unchanged, so:

  • Every current Playwright assertion method is available automatically.
  • Every future Playwright assertion method will be available automatically.
  • All assertion options (timeout, ignore_case, use_inner_text, regex, lists, …) pass through to Playwright without modification.
  • Playwright's auto-retry, error messages, and call logs are fully preserved.
  • No Playwright assertion logic is reimplemented.

Failure collection and per-test reporting are handled by Playwright's own _soft_scope() mechanism, activated by the pytest_runtest_call hook registered by this package.

Installation

pip install pytest-playwright-softassert

Usage

Sync

from pytest_playwright_softassert import soft_expect

def test_example(page):
    soft_expect(page.get_by_role("button", name="Save")).to_be_visible()
    soft_expect(page.get_by_text("Success")).to_have_text("Success")
    soft_expect(page).to_have_url("/dashboard")
    soft_expect(response).to_be_ok()

With custom message

soft_expect(
    page.get_by_role("heading"),
    "Dashboard heading must be visible"
).to_be_visible()

With assertion options

import re

soft_expect(locator).to_have_text("Hello", timeout=10_000, ignore_case=True)
soft_expect(locator).to_have_text(re.compile(r"Order\s+\d+"))
soft_expect(locator).to_have_text(["Item 1", "Item 2", "Item 3"])

Negative assertions

soft_expect(locator).not_to_be_visible()
soft_expect(locator).not_to_have_text("Error")
soft_expect(page).not_to_have_url(re.compile(r"/error"))

Async

from pytest_playwright_softassert import async_soft_expect

async def test_example(page):
    await async_soft_expect(locator).to_be_visible()
    await async_soft_expect(page).to_have_url("/dashboard")

Behaviour

Scenario Behaviour
Soft assertion passes Test continues normally
Soft assertion fails Failure collected; test continues
All soft assertions pass Test passes
One or more soft assertions fail Test marked FAILED at the end
Hard expect() fails Test fails immediately (unchanged)

Running the compatibility tests

pytest tests/test_compatibility.py -v

These tests verify that soft_expect exposes the same assertion method surface as Playwright's native expect() for LocatorAssertions, PageAssertions, and APIResponseAssertions. They run without a browser and should be included in CI.

Running the integration tests

playwright install chromium
pytest tests/test_integration.py --browser chromium -v

Metadata

Release files for pytest-playwright-softassert 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-playwright-softassert 1.0.0
File Size Uploaded Provenance
pytest_playwright_softassert-1.0.0.tar.gz 8.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-playwright-softassert 1.0.0
File Interpreter ABI Platform
pytest_playwright_softassert-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / pytest_playwright_softassert-1.0.0.tar.gz

Download URL pytest_playwright_softassert-1.0.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
87a1226b1853503a9f8f730ec0b92a493bade7c486c123be4c712427f9d26f4b
BLAKE2b-256 checksum
How to use checksums
e4dcfc0ed6ac21e02a7526481546e23ba2136ecf9a0941423304715bf66eaf29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pytest_playwright_softassert-1.0.0-py3-none-any.whl

Download URL pytest_playwright_softassert-1.0.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed80d067647408872c98016988d79c4b31316d2dd115475940d398d89dff03f3
BLAKE2b-256 checksum
How to use checksums
6d8ef12430cf35980c0a328093bd05b476ad859288ebd46279b20c7966decffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pytest-playwright-softassert 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page