Skip to content

Force a DOM anchor on the navigation and teardown drains #285

Closed

Description

@vishnuv688

Part of #277

The JS drain uses collectorDrainExpression(forceAnchor) so a
freshly injected collector's async anchor is not lost. Python's drain never forces
an anchor, so a navigation destination's DOM can be missed entirely. Scope shrinks
once #284 lands, because the preload removes most of the race; keep this as the
narrow backstop the JS side kept.

Acceptance criteria

The post-navigation and teardown drains force a full-DOM
anchor. A short-lived destination page still anchors. Regression test over the
pure drain payload handling.

Size: M. Depends on #284.

Activity

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

    @vishnuv688
    MemberAuthor

    Re-scoped after the preload landed (#317)

    This issue anticipated it — "scope shrinks once A6 lands... keep this as the narrow backstop the JS side kept" — so recording what is left.

    The navigation half is covered. With the collector registered as a document-start preload, every document instruments itself before any of its own script runs and anchors its own DOM at its own performance.timeOrigin. There is nothing to force, because the anchor is no longer racing an injection. Measured on examples/selenium/python-test/login.py, which visits three documents (/login → /secure → /login):

    with preload   3 anchors, 36 mutations, 0 script injections
    <script> path  2 anchors, 31 mutations, 1 script injection
    

    The one the old path missed is the second visit to /login after logout — a different document with the same URL.

    The teardown half is not. collectorDrainExpression(forceAnchor) has no Python equivalent, and the final drain before driver.quit() still never forces an anchor. A page whose document was replaced shortly before teardown can therefore end the run unanchored, and no later command exists to drain it.

    Also still open: the preload does not help a session created without webSocketUrl, where the <script> path is the only capture and the original race is intact. That is the case the JS side deliberately kept its backstop for.

    Suggested remaining scope: force an anchor on the teardown drain, and on the <script>-path drains when no preload is registered. The navigation-drain half can be dropped.

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