Skip to content

[πŸ› Bug]: start_devtools() issues command to wrong TargetHandlerΒ #15803

@victorvianna

Description

@victorvianna

Description

Repro instructions: run this on 4.33.0

cdp, conn = webdriver.Chrome(service=service, options=options).start_devtools()
conn.execute(cdp.target.send_message_to_target(str(next(cdp.network.enable())), conn.session_id))

Expected: it works
Actual:

Exception: {'code': -32602, 'message': 'No session with given id'}

After adding various debug logs to selenium, chrome and chromedriver, I was able to verify the following:

  • This in selenium triggers this in Chrome with this=Handler1, target_id="Target1" and out_session_id="Session1".
  • But later when the Network.enable() command is issued, it arrives here with this=Handler2, target_id=std::nullopt, and session_id="Session1". Thus, failing this lookup

Possibly related: is it actually correct that start_devtools() arbitrarily attaches to the first handler returned by Target.getTargets() here? My understanding is these handlers map to different functionalities of the protocol, e.g. there is a a NetworkHandler responsible for Network.* commands.

Reproducible Code

See above

Debugging Logs

See above

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-pyPython BindingsD-chromeI-defectSomething is not working as intendedOS-mac

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions