[{"data":1,"prerenderedAt":74},["ShallowReactive",2],{"content-\u002Fbuild-with-code\u002Fplaywright":3,"content-doc-\u002Fbuild-with-code\u002Fplaywright-inline":3},{"id":4,"title":5,"body":6,"date":65,"description":66,"extension":67,"meta":68,"navigation":69,"order":65,"path":70,"seo":71,"stem":72,"__hash__":73},"content\u002Fbuild-with-code\u002Fplaywright.md","Run Playwright in the Cloud, One connectOverCDP Line | axiom.ai",{"type":7,"value":8,"toc":61},"minimark",[9,16,24,33,43,54],[10,11],"left-hero",{"description":12,"primaryText":13,"primaryTo":14,"title":15},"Point connectOverCDP at our WebSocket and the script you already have runs on fresh cloud Chrome. You manage your script. We manage Chrome.","Get API key","https:\u002F\u002Fcode.axiom.ai","Run Playwright in the cloud. Change one line.",[17,18],"api-code-example",{"caption":19,"code":20,"linkText":21,"name":22,"to":23},"Point connectOverCDP at our WebSocket. The rest of your script doesn't change.","import { chromium } from \"playwright\";\n\nconst browser = await chromium.connectOverCDP(\n  `wss:\u002F\u002Fcdp-lb.axiom.ai\u002F?token=${process.env.AXIOM_API_KEY}`\n);\n\nconst context = browser.contexts()[0];\nconst page = context.pages()[0] ?? await context.newPage();\n\nawait page.goto(\"https:\u002F\u002Fexample.com\");\nawait page.getByRole(\"button\", { name: \"Accept\" }).click();\nawait page.screenshot({ path: \"out.png\" });\n\nawait browser.close();\n","Read the Chrome API docs","Playwright","\u002Fdocs\u002Fdeveloper-hub\u002Fapi\u002Fcdp",[25,26],"feature-list",{":items":27,"description":28,"eyebrow":29,"link":30,"linkText":31,"title":32},"[{\"title\":\"Swap launch() for connectOverCDP\",\"description\":\"Add your API key and run. Same one-line change in Node, Python, Java, and .NET.\",\"to\":\"\u002Fbuild-with-code\u002Fapi\u002Fchrome\",\"linkText\":\"Explore the Chrome API\",\"code\":\"const browser = await chromium.connectOverCDP(\\n  `wss:\u002F\u002Fcdp-lb.axiom.ai\u002F?token=${KEY}`\\n);\\n\"},{\"title\":\"No Chromium install\",\"description\":\"Every session gets current cloud Chrome. Nothing to download in CI, nothing to rebuild when Chromium updates.\"},{\"title\":\"Scale your sessions\",\"description\":\"Up to 20 concurrent sessions in the cloud, unlimited on desktop, and more on request. Parallel work means more connections, not more servers, and runtime only meters while a session is open.\",\"to\":\"\u002Finfrastructure\",\"linkText\":\"See infrastructure\"},{\"title\":\"Your data stays yours\",\"description\":\"Each cloud session gets its own server with a private Docker container, desktop runs never leave your machine, and we never train AI on anything that passes through either.\"}]","Your script connects to a browser in our cloud instead of launching its own. Nothing else changes.","The switch","\u002Fbuild-with-code\u002Fapi\u002Fchrome","Explore the Chrome API","Stop launching Chromium. Connect to ours.",[34,35],"code-tiles-grid",{":reverse-stagger":36,":tiles":37,"description":38,"eyebrow":39,"link":40,"linkText":41,"title":42},"true","[{\"title\":\"Log in and scrape\",\"code\":\"await axiom.browserOpen();\\ntry {\\n  await axiom.goto(\\\"https:\u002F\u002Fexample.com\u002Flogin\\\");\\n  await axiom.enterText(\\\"#email\\\", \\\"user@example.com\\\");\\n  await axiom.enterText(\\\"#password\\\", process.env.PW);\\n  await axiom.click(\\\"button[type=submit]\\\");\\n  await axiom.wait(2000);\\n\\n  const rows = await axiom.scrape(null, { hierarchy: \\\".product-card\\\" }, null, 50, {});\\n} finally {\\n  await axiom.browserClose();\\n}\\n\"},{\"title\":\"Fill in a form\",\"code\":\"await axiom.goto(\\\"https:\u002F\u002Fexample.com\u002Fapply\\\");\\nawait axiom.enterText(\\\"#full-name\\\", row.name);\\nawait axiom.selectList(\\\"#country\\\", row.country);\\nawait axiom.click(\\\"button[type=submit]\\\");\\n\"},{\"title\":\"Use AI mid-run\",\"code\":\"const [[title], [description]] = await axiom.scrapeMetadata([\\n  { id: \\\"general_metadata_title\\\" },\\n  { id: \\\"meta_description\\\", value: 'meta[name=\\\"description\\\"]' }\\n]);\\nconst verdict = await axiom.integrateAI({\\n  aiFunction: \\\"generate\\\",\\n  prompt: `Product page or category page? ${title} ${description}`\\n});\\n\"},{\"title\":\"Combine with your own code\",\"code\":\"const targets = await db.query(\\\"SELECT url FROM watchlist\\\");\\n\\nawait axiom.browserOpen();\\ntry {\\n  for (const { url } of targets) {\\n    await axiom.goto(url);\\n    const [[price]] = await axiom.scrape(null, { hierarchy: \\\".price\\\" }, null, 1, {});\\n    if (Number(price) \u003C 100) await notifySlack(url, price);\\n  }\\n} finally {\\n  await axiom.browserClose();\\n}\\n\"}]","The browser you connected to also takes Step API calls, functions from the engine behind our No-Code Tool. One call scrapes a paginated list, solves a captcha, or walks a date picker, using the selectors you already have.","Also available","\u002Fbuild-with-code\u002Fapi\u002Fstep","Explore the Step API","Mix Step API calls into the same script.",[44,45,48],"grid-fade-wrap",{"bg":46,"color":47},"gray-to-white","default",[49,50],"call-to-action",{":shapes":51,"headline":52,"linkText":13,"linkTo":14,"text":53},"[\"cube\"]","Get an API key and try the Chrome API for free.\n","2 free hours of runtime. No card required.",[55,56],"cross-links",{":links":57,"className":58},"[{\"eyebrow\":\"Go deeper\",\"title\":\"Chrome API\",\"to\":\"\u002Fbuild-with-code\u002Fapi\u002Fchrome\"},{\"eyebrow\":\"Go deeper\",\"title\":\"Step API\",\"to\":\"\u002Fbuild-with-code\u002Fapi\u002Fstep\"}]",[59,60],"gray","iso-grid-gray-100",{"title":62,"searchDepth":63,"depth":63,"links":64},"",3,[],null,"Run Playwright in the cloud on axiom.ai. One connectOverCDP line and your Playwright code drives fresh cloud Chrome from Node, Python, Java, or .NET.","md",{},true,"\u002Fbuild-with-code\u002Fplaywright",{"title":5,"description":66},"build-with-code\u002Fplaywright","T9TUMNf7rkNLnlCBMm8oEUi9O6qttUTJfS1zVkiVY6Q",1785947370976]