Cloud Code + Playwright CLI Automates Browsers End-to-End

Pair Cloud Code with Playwright CLI to control browsers for QA testing, data scraping, and logged-in tasks; scripts iteratively improve via agent feedback, saving tokens over MCP tools.

Setup Playwright CLI for Token-Efficient Browser Control

Install Playwright CLI in a Cloud Code project via plan mode prompt: "Use Playwright CLI for browser automation like testing web apps or screenshots." Cloud Code initializes the project, installs dependencies, and tests with a demo script opening a page and capturing a screenshot. This CLI approach saves tokens compared to Chrome DevTools MCP, which bloats context with dozens of tool descriptions. Run in headed mode (visible browser) for observation or headless for background tasks. Turn scripts into reusable skills for consistent automation, e.g., "QA the website" invokes test-feedback-fix loops.

Scripts launch browsers, interact via selectors (e.g., fill fields, click buttons), take screenshots for analysis, and adapt. Persistent browser profiles preserve logins by launching with existing Chrome user data, enabling session-based tasks without repeated authentication.

Self-QA Multi-Page Web Apps: Build, Test, Iterate

Prompt Cloud Code to build a 12-page onboarding form (first name, last name, phone, business details, etc.) with per-page navigation via 'Continue' buttons and a progress bar. It auto-generates HTML/JS files, spins up a localhost server, and takes build screenshots.

For QA, prompt: "Spin up server, use browser to test filling fields and clicking through in headed mode; note bugs and fix the site." It writes a qa-test.js script to simulate user flow: fill forms (e.g., 'Nathan Harrison', phone), select dropdowns (e.g., company size), submit. First run catches bugs like Enter key failing on textarea, review page not loading due to stale overlay. Analyzes screenshots, patches code (e.g., fix navigation handlers), restarts server, and retests until passing—achieving hands-off validation. Scale by spinning multiple bots for edge cases (X, Y, Z tests) in parallel headed/headless browsers.

Scrape Data and Handle Logged-In Sessions Adaptively

For extraction, prompt to build a script searching Google for "dentist offices in California," collect links, visit sites, extract phone numbers. First run fails (Google blocks automation), so it switches to DuckDuckGo, visits pages, clicks 'Contact' even if numbers are visible, grabs 5+ phones via screenshots/script updates. Instruct persistence: "Don't stop until finding five phone numbers"—agent refines selectors iteratively.

Logged-in demo on school.com: Use persistent profile for community 'wins' channel. Initial script navigates, finds heart SVG buttons, but double-clicks (like/unlike). Feedback fixes: sort by 'newest' via menu, check yellow thumbs-up icon before liking, skip duplicates, paginate. After 4-5 runs, it reliably likes all posts autonomously. Manual first login saves session for future headless runs.

Scale to Scheduled Autonomous Agents

Deploy refined Playwright skills in Cloud Code desktop app for cron-like tasks. Example: 'AIS agent' bot in school.com community runs daily—engages wins (likes newest posts), posts AI news roundups, responds to notifications, votes polls (self-learned script). On mention (e.g., "respond to happy birthday comments"), it lists tasks, launches headed browser, replies under each (tags users, submits). Errors trigger agentic retries; UI learning improves over runs (e.g., mark notifications read). Headless for stealth; headed for debugging. Compare CLIs (Playwright vs. forcell agent browser, open CLI) by token efficiency and script-learning performance. Next: Schedule via desktop app for always-on autonomy.

Summarized by x-ai/grok-4.1-fast via openrouter

8598 input / 1995 output tokens in 17091ms

© 2026 Edge