--- title: Playwright | Lightcone description: Connect Playwright to Lightcone browser sessions via Chrome DevTools Protocol. --- Connect [Playwright](https://playwright.dev) to Lightcone’s cloud browsers via Chrome DevTools Protocol (CDP). This gives you the full Playwright API running on Lightcone’s stealth-enabled, scalable browser infrastructure. ## Install Terminal window ``` pip install tzafon playwright playwright install chromium ``` Terminal window ``` npm install @tzafon/lightcone playwright npx playwright install chromium ``` ## Example ``` from tzafon import Lightcone from playwright.sync_api import sync_playwright client = Lightcone() session = client.computers.create(kind="browser") # Get the CDP endpoint from the session cdp_url = session.endpoints.get("cdp") with sync_playwright() as p: # Connect Playwright to the remote browser browser = p.chromium.connect_over_cdp(cdp_url) page = browser.contexts[0].pages[0] # Use the full Playwright API page.goto("https://example.com") page.fill("input[name='search']", "hello world") page.click("button[type='submit']") # Wait for results page.wait_for_selector(".results") content = page.inner_text("body") print(content[:500]) browser.close() client.computers.delete(session.id) ``` ``` import Lightcone from "@tzafon/lightcone"; import { chromium } from "playwright"; const client = new Lightcone(); const session = await client.computers.create({ kind: "browser" }); const cdpUrl = session.endpoints?.cdp; const browser = await chromium.connectOverCDP(cdpUrl!); const page = browser.contexts()[0].pages()[0]; await page.goto("https://example.com"); await page.fill("input[name='search']", "hello world"); await page.click("button[type='submit']"); await page.waitForSelector(".results"); const content = await page.innerText("body"); console.log(content.slice(0, 500)); await browser.close(); await client.computers.delete(session.id!); ``` ## Async Python ``` from tzafon import AsyncLightcone from playwright.async_api import async_playwright client = AsyncLightcone() session = await client.computers.create(kind="browser") cdp_url = session.endpoints.get("cdp") async with async_playwright() as p: browser = await p.chromium.connect_over_cdp(cdp_url) page = browser.contexts[0].pages[0] await page.goto("https://example.com") # ... await browser.close() await client.computers.delete(session.id) ``` ## Why use Playwright with Lightcone? - **Full Playwright API** — selectors, waiters, assertions, network interception, file uploads/downloads - **Cloud execution** — no local browser needed - **Stealth & proxies** — Lightcone’s anti-detection features - **Scale** — spin up hundreds of sessions in parallel The Playwright integration is also the foundation for other framework integrations like [Browser-Use](/integrations/browser-use/index.md), [OpenAI CUA](/integrations/openai-cua/index.md), and [Anthropic Claude](/integrations/anthropic-claude/index.md). ## Resources - [Playwright Python docs](https://playwright.dev/python/docs/intro) - [Playwright Node.js docs](https://playwright.dev/docs/intro) ## See also - [**Browser-Use**](/integrations/browser-use/index.md) — AI web agents using Playwright + Lightcone - [**OpenAI CUA**](/integrations/openai-cua/index.md) — OpenAI’s computer-use agent over CDP - [**Computers**](/guides/computers/index.md) — Lightcone’s native API (no Playwright needed)