Playwright
Connect Playwright to Lightcone browser sessions via Chrome DevTools Protocol.
Connect Playwright 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
Section titled “Install”pip install tzafon playwrightplaywright install chromiumnpm install @tzafon/lightcone playwrightnpx playwright install chromiumExample
Section titled “Example”from tzafon import Lightconefrom playwright.sync_api import sync_playwright
client = Lightcone()session = client.computers.create(kind="browser")
# Get the CDP endpoint from the sessioncdp_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
Section titled “Async Python”from tzafon import AsyncLightconefrom 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?
Section titled “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
Resources
Section titled “Resources”See also
Section titled “See also”- Browser-Use — AI web agents using Playwright + Lightcone
- OpenAI CUA — OpenAI’s computer-use agent over CDP
- Computers — Lightcone’s native API (no Playwright needed)