Skip to content

browser: add chromium.connectOverCDP for external browsers#6005

Draft
inancgumus wants to merge 2 commits into
masterfrom
chromium-connect
Draft

browser: add chromium.connectOverCDP for external browsers#6005
inancgumus wants to merge 2 commits into
masterfrom
chromium-connect

Conversation

@inancgumus

@inancgumus inancgumus commented May 19, 2026

Copy link
Copy Markdown
Contributor

What?

Scripts can connect to external CDP-compatible browsers at runtime without declaring options.browser.

import { chromium } from 'k6/browser';

export default async function () {
  const browser = await chromium.connectOverCDP('ws://...');
  const page = await browser.newPage();
  // ...
  await page.close();
  await browser.close();
}

The naming follows Playwright's chromium.connectOverCDP().

Why?

Users with their own browser infrastructure want to run k6 browser tests against their own browsers. Their flow requires a fresh WebSocket URL per session, obtained at runtime via an API call.

Note

CI failures are not related to this PR.

@inancgumus inancgumus self-assigned this May 19, 2026
@inancgumus inancgumus temporarily deployed to azure-trusted-signing May 19, 2026 16:40 — with GitHub Actions Inactive
@inancgumus inancgumus temporarily deployed to azure-trusted-signing May 19, 2026 16:42 — with GitHub Actions Inactive
Scripts can now connect to external browser instances at
runtime via import { chromium } from 'k6/browser' and
chromium.connect(wsURL). This bypasses the managed browser
registry entirely - users control the browser lifecycle.

Enables use cases like Browserbase where session URLs are
dynamic and fetched per-iteration from an external API.
No cloud or SM platform changes needed: scripts without
options.browser skip the entire managed browser pipeline.
Shows chromium.connectOverCDP() with an external browser
provided via K6_BROWSER_WS_URL. No options.browser needed.
@inancgumus inancgumus temporarily deployed to azure-trusted-signing June 5, 2026 19:12 — with GitHub Actions Inactive
@inancgumus inancgumus temporarily deployed to azure-trusted-signing June 5, 2026 19:14 — with GitHub Actions Inactive
@peterschretlen

Copy link
Copy Markdown

This looks to be a related issue? #4357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants