feat(selenium-devtools-py): register the collector at document start via BiDi preload - #317
Merged
Conversation
Greptile SummaryThe 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.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| 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
Reviews (4): Last reviewed commit: "fix(selenium-devtools-py): recover a doc..." | Re-trigger Greptile
Member
Author
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Type of change
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-pyNotes for reviewers
Screenshots / recordings