Skip to content

Assertion capture #291

Closed
Closed

Description

@vishnuv688

Part of #277

No assertion rows are captured. The JS side patches node:assert
through core/assert-patcher and renders passing and failing rows; a pytest
assertion is a rewritten assert statement, so the mechanism has to differ.

Acceptance criteria

Failing and passing assertions appear as rows carrying
expected and actual. The Errors tab collects the failures.

Activity

  1. self-assigned this
    on Aug 12, 2026
  2. vishnuv688 commented on Aug 17, 2026

    @vishnuv688
    MemberAuthor

    Scope note: plain scripts have no interception point

    This issue is written around pytest, whose assertion rewriting is what makes interception possible. A plain script has no equivalent hook: assert is a bare language statement, and the adapter instruments WebDriver.execute, so an assert never touches the driver and cannot be observed at all.

    Reproduced on the new login example (examples/selenium/python-test/login.py) with a deliberately broken assertion. Neither passing nor failing assertions produce a row, and nothing in the current acceptance criteria would change that for this style of run.

    So the acceptance criteria need to say which of these is in scope:

    • pytest — hook the rewritten assertion (pytest_assertrepr_compare or the plugin's own reporting) and attach rows to the running test. This is what the issue assumes today.
    • plain script — there is no interception point, so it needs either an opt-in API the user calls (e.g. devtools.expect(...)) or an explicit statement that plain scripts are out of scope.

    Worth resolving before implementation, because the two need different mechanisms and the plain-script path is the one the example in the docs uses.

    Related but distinct, and currently untracked

    The same run surfaced a separate defect that this issue would not fix: _send_default_suite is called with a hardcoded "passed" (packages/selenium-devtools-py/src/selenium_devtools/instrumentation.py:356) and the adapter has no failure path, so a plain-script run that raises still reports a green 1/1. The command stream stops at the failing line while the test tree claims a pass. Independent of assertion capture and needs its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestselenium-devtools-pyPython Selenium adapter for the DevTools dashboard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions