Skip to content

Browser: Align chromium.connectOverCDP with Playwright #6179

Description

@joanlopez

Background

chromium.connectOverCDP(wsEndpoint) was introduced in this PR with a minimal signature: a single WebSocket endpoint string, with browser options parsed from the environment (K6_BROWSER_TIMEOUT, K6_BROWSER_DEBUG, log filter).

Playwright's browserType.connectOverCDP() is richer, and we intentionally did not match it in the initial PR to keep scope tight. This issue tracks that divergence so it's a deliberate decision rather than an accidental gap.

Playwright parity we deferred

  1. Optional options argument { timeout, headers }.
  • Per-call timeout to override the env-derived connect timeout.
  • headers sent with the connect (upgrade) request. Needed by providers that authenticate the CDP connection via headers.
  • Adding an optional trailing options arg is backwards-compatible, so it can land later without breaking the string-only signature.
  1. Accept an HTTP(S) endpoint and resolve the WS URL via /json/version.
  • Playwright accepts an http(s)://host:port endpoint and fetches the browser-level WebSocket URL from /json/version.
  • This is convenient because the browser-level WS URL embeds a random GUID that changes per launch, so users would otherwise have to discover it themselves.

Rationale

headers only matters for providers that authenticate the connect request that way, and the options arg is additive: none of it is really required for the base feature. Capturing it here keeps the API divergence from Playwright explicit and gives us a place to discuss whether/when to close it.

Feel free to add your 👍🏻 to this issue, to express interest, or to explicitly comment out with your concrete needs and/or use case.

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions