Skip to Content
UsageCDPPlaywright

Playwright

Use Lightpanda with Playwright via the Chrome DevTools Protocol (CDP).

More examples in demo/playwright.

Start Lightpanda as a local CDP server (see serve command for all options):

./lightpanda serve --host 127.0.0.1 --port 9222

Connect Playwright using chromium.connectOverCDP:

import { chromium } from 'playwright-core'; const browser = await chromium.connectOverCDP('ws://127.0.0.1:9222'); const context = await browser.newContext({}); const page = await context.newPage(); await page.goto('https://wikipedia.com/'); const title = await page.locator('h1').textContent(); console.log(title); await page.close(); await context.close(); await browser.close();