Part of #277
Selenium PR 17761 generates the Python BiDi protocol layer from the
shared binding-neutral schema and states that higher-level convenience methods
follow. Today the adapter uses a private connection, constructs NetworkEvent
itself and hand-rolls Session.subscribe.
Unblocked: that release shipped as selenium 4.44. The same release removed
what the adapter was using — NetworkEvent left bidi.network and
Network.conn became _conn — so network capture has been silently dead on
4.44+ ever since: no error, just an empty Network tab behind one warning. This
is a shipped regression, not forward-looking cleanup. Bisected from the wheels:
4.43 carries both names, 4.44 carries neither.
Acceptance criteria
Network capture uses the public API with no private
connection access. Handlers read typed records as well as params dicts. Event
names come from the generated enums. Adoption is capability-gated so older
selenium keeps working.
What the API turned out to be (PR #319)
Not met as written: the public API is reachable, but not without private
access. Capture registers against the event manager behind
Network.add_event_handler rather than calling the method, because the
deserializer has to be passed in rather than looked up (see the next point). The
registration is selenium's own add_event_handler body with that one
substitution, and it depends on six private members: _event_manager with its
conn, subscribe_to_event and add_callback_to_tracking, plus
remove_callback, remove_callback_from_tracking and unsubscribe_from_event
for the failure path. Each is pinned by a test against the installed selenium.
The fully-public route — writing the adapter's deserializer into the per-event
map add_event_handler reads — was implemented first and then withdrawn. The
swap has to stay in place across the websocket subscribe, so any handler another
subscriber registers for those events during that round trip closes over the
adapter's deserializer and receives dicts where it expects selenium's generated
objects. Passing the deserializer in writes nothing shared, so no such window
exists. That is the trade: calling private methods, rather than mutating state
other subscribers read.
add_request_handler/add_response_handler were rejected outright — both
register an intercept even in their high-level form, pausing every request until
selenium continues it.
Invalidated: typed records. The generated event dataclasses model only each
event's own extension field — BeforeRequestSentParameters declares just
initiator, ResponseCompletedParameters just response — and the
deserializer DROPS every param not declared, taking the request, its id and the
timestamp with it. A response deserialized that way has nothing to correlate
against, so handlers read the raw params instead.
Not met: generated enums. The adapter supplies its own event-name constants
rather than reading them from selenium's.
Dropped: capability gating for older selenium. The package is unpublished,
so it now requires selenium 4.44+ (and Python 3.10+, which 4.44 itself requires)
rather than carrying a second subscription path for releases predating its own
first one.
Follow-ups this left behind
bidi.py is over the repo's 500 logic-line soft cap; the selenium wiring is
the natural extraction, and Python is not linted so nothing enforces it.
BiDi attached — capturing console + network is logged when either channel
attaches, so it overstates when only one did.
Depends on #281.
Part of #277
Selenium PR 17761 generates the Python BiDi protocol layer from the
shared binding-neutral schema and states that higher-level convenience methods
follow. Today the adapter uses a private connection, constructs
NetworkEventitself and hand-rolls
Session.subscribe.Unblocked: that release shipped as selenium 4.44. The same release removed
what the adapter was using —
NetworkEventleftbidi.networkandNetwork.connbecame_conn— so network capture has been silently dead on4.44+ ever since: no error, just an empty Network tab behind one warning. This
is a shipped regression, not forward-looking cleanup. Bisected from the wheels:
4.43 carries both names, 4.44 carries neither.
Acceptance criteria
Network capture uses the public API with no private
connection access. Handlers read typed records as well as
paramsdicts. Eventnames come from the generated enums. Adoption is capability-gated so older
selenium keeps working.
What the API turned out to be (PR #319)
Not met as written: the public API is reachable, but not without private
access. Capture registers against the event manager behind
Network.add_event_handlerrather than calling the method, because thedeserializer has to be passed in rather than looked up (see the next point). The
registration is selenium's own
add_event_handlerbody with that onesubstitution, and it depends on six private members:
_event_managerwith itsconn,subscribe_to_eventandadd_callback_to_tracking, plusremove_callback,remove_callback_from_trackingandunsubscribe_from_eventfor the failure path. Each is pinned by a test against the installed selenium.
The fully-public route — writing the adapter's deserializer into the per-event
map
add_event_handlerreads — was implemented first and then withdrawn. Theswap has to stay in place across the websocket subscribe, so any handler another
subscriber registers for those events during that round trip closes over the
adapter's deserializer and receives dicts where it expects selenium's generated
objects. Passing the deserializer in writes nothing shared, so no such window
exists. That is the trade: calling private methods, rather than mutating state
other subscribers read.
add_request_handler/add_response_handlerwere rejected outright — bothregister an intercept even in their high-level form, pausing every request until
selenium continues it.
Invalidated: typed records. The generated event dataclasses model only each
event's own extension field —
BeforeRequestSentParametersdeclares justinitiator,ResponseCompletedParametersjustresponse— and thedeserializer DROPS every param not declared, taking the request, its id and the
timestamp with it. A response deserialized that way has nothing to correlate
against, so handlers read the raw
paramsinstead.Not met: generated enums. The adapter supplies its own event-name constants
rather than reading them from selenium's.
Dropped: capability gating for older selenium. The package is unpublished,
so it now requires selenium 4.44+ (and Python 3.10+, which 4.44 itself requires)
rather than carrying a second subscription path for releases predating its own
first one.
Follow-ups this left behind
bidi.pyis over the repo's 500 logic-line soft cap; the selenium wiring isthe natural extraction, and Python is not linted so nothing enforces it.
BiDi attached — capturing console + networkis logged when either channelattaches, so it overstates when only one did.
Depends on #281.