Skip to content

feat(selenium-devtools-py): register the collector at document start via BiDi preload - #317

Merged
vishnuv688 merged 4 commits into
mainfrom
vv/284-bidi-preload
Aug 18, 2026
Merged

feat(selenium-devtools-py): register the collector at document start via BiDi preload#317
vishnuv688 merged 4 commits into
mainfrom
vv/284-bidi-preload

Conversation

@vishnuv688

@vishnuv688 vishnuv688 commented Aug 18, 2026

Copy link
Copy Markdown
Member

What & why

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

Packages touched

  • shared (types and contracts)
  • core (framework-agnostic capture/reporting)
  • elements (published element/snapshot API — @wdio/elements)
  • service (WebdriverIO adapter)
  • nightwatch-devtools (Nightwatch adapter)
  • selenium-devtools (Selenium adapter)
  • backend (server)
  • app (UI)
  • script (page-injected runtime)
  • selenium-devtools-py

Notes for reviewers

Screenshots / recordings

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

Greptile Summary

The PR registers the Python Selenium collector as a session-wide BiDi preload so new documents are instrumented from document start, while retaining per-document injection as a fallback.

  • Adds BiDi preload registration with capability and failure handling.
  • Separates raw collector-source loading from the injectable IIFE wrapper.
  • Recovers documents missed by preload registration when a trace read reports that the collector is absent.
  • Adds focused tests for registration, fallback behavior, recovery, and Selenium’s global preload call shape.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/selenium-devtools-py/src/selenium_devtools/bidi_preload.py Adds capability-gated, session-wide BiDi preload registration with graceful fallback.
packages/selenium-devtools-py/src/selenium_devtools/instrumentation.py Registers the collector preload during session setup and passes preload state into snapshot capture.
packages/selenium-devtools-py/src/selenium_devtools/snapshot.py Separates raw and wrapped collector sources and adds trace-read-driven recovery for documents without a collector.
packages/selenium-devtools-py/tests/test_bidi_preload.py Covers preload registration, fallback behavior, missed-document recovery, and Selenium API dispatch.
packages/selenium-devtools-py/tests/test_snapshot.py Updates snapshot injection tests for readiness-first probing and retryable source loading.

Sequence Diagram

sequenceDiagram
    participant Setup as Session setup
    participant BiDi as Selenium BiDi
    participant Page as Current document
    participant Snap as SnapshotCapturer

    Setup->>BiDi: Pin collector preload
    alt Registration succeeds
        BiDi->>Page: Run collector at document start
        Setup->>Snap: "Start with preloaded=true"
    else BiDi unavailable
        Setup->>Snap: "Start with preloaded=false"
        Snap->>Page: Inject collector script
    end

    Snap->>Page: Read and drain trace
    alt Collector absent
        Snap->>Page: Inject fallback collector
        Snap->>Page: Read trace again
    end
Loading

Reviews (4): Last reviewed commit: "fix(selenium-devtools-py): recover a doc..." | Re-trigger Greptile

Comment thread packages/selenium-devtools-py/src/selenium_devtools/snapshot.py
@vishnuv688 vishnuv688 changed the title Vv/284 bidi preload feat(selenium-devtools-py): register the collector at document start via BiDi preload Aug 18, 2026
Comment thread packages/selenium-devtools-py/src/selenium_devtools/snapshot.py
@vishnuv688

Copy link
Copy Markdown
Member Author

@greptile-apps

@vishnuv688
vishnuv688 merged commit 8a39704 into main Aug 18, 2026
11 checks passed
@vishnuv688 vishnuv688 linked an issue Aug 18, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Register the collector at document start via BiDi preload

1 participant