Skip to main content
Playwright is a browser automation library from Microsoft. Kernel browsers speak the Chrome DevTools Protocol (CDP), so you can point an existing Playwright script at a cloud browser by swapping your launch call for a connectOverCDP to the session’s cdp_ws_url — no other code changes.
If you don’t need a local Playwright install and want your code to run co-located with the browser, use Playwright Execution instead. It runs the same Playwright API inside the browser’s VM and returns values back to your agent. This page covers connecting a Playwright client you run yourself.

Install

Create a browser and connect

Create a Kernel browser, then connect Playwright to its cdp_ws_url. Kernel opens a context and page for you — grab them from the connected browser rather than calling newContext.

Configure the viewport

Set the viewport when you create the browser, not through Playwright. Playwright’s setViewportSize is a no-op over a CDP connection — the window size is fixed at browser creation. See Viewports for supported dimensions and refresh rates.

Stealth mode

Create the browser with stealth: true to harden it against bot detection. The connection is unchanged — you still connect Playwright to cdp_ws_url.
See stealth mode for what it changes. For the strongest anti-detection posture, prefer computer controls or Playwright Execution — a direct CDP connection carries a fingerprint that co-located control avoids.

Why run Playwright on Kernel

  • No local browser management. No Chromium download or version pinning on your machine — the browser runs in Kernel’s cloud.
  • Persistent state. Keep cookies and login state across runs with Profiles.
  • Scale out. Launch many sessions in parallel instead of contending for one local browser.
  • Debuggable. Watch any session in real time with live view.
  • No code rewrite. Existing Playwright scripts work as-is once you swap the launch for connectOverCDP.

Next steps