# Cloud Browser Automation Proof [![verify](https://github.com/lucprooffirst/cloud-browser-automation-proof/actions/workflows/ci.yml/badge.svg)](https://github.com/lucprooffirst/cloud-browser-automation-proof/actions/workflows/ci.yml) ![Four passing browser-automation checks](./demo.svg) A compact, provider-neutral proof that a Chrome DevTools Protocol (CDP) session can be controlled with both Playwright and Puppeteer. The suite also launches five isolated profiles concurrently. A separate cold-restart check stops Chrome completely, relaunches the same local profile directory, and verifies the saved state again. This repository was prepared as an application-specific technical sample for Proof First Engineering. It does not claim prior access to, or validation against, any particular commercial cloud-browser provider. Point it at a real provider only with an authorized endpoint. ## What is proven - **Playwright over CDP:** connect once, navigate an authorized target, extract its title and first heading, then close the browser session. - **Puppeteer over CDP:** perform the same bounded check through Puppeteer's API and close the browser session. - **Parallel isolation:** launch five separate local Chrome profiles, write a distinct value in each, and verify that no profile leaks another profile's state. Cloud mode requires five distinct endpoints. - **Cold-restart persistence:** stop the browser process, launch a new process against the same profile directory, and assert that origin state remains. - **Deterministic local verification:** `npm test` always uses temporary local Chrome profiles and loopback fixture servers; it never consumes cloud quota. - **Credential hygiene:** endpoint credentials and query tokens are redacted from errors and reports, with regression checks for HTTP(S) and WebSocket endpoint forms. ## Architecture ```mermaid flowchart LR A[Local Chrome] -->|CDP WebSocket| B[Playwright example] A -->|CDP WebSocket| C[Puppeteer example] A -->|five CDP endpoints| D[Parallel profile example] E[Authorized cloud browser] -->|CDP WebSocket| B E -->|CDP WebSocket| C E -->|five CDP endpoints| D B --> T[Target URL] C --> T D --> T T --> L[Loopback fixture in local tests] T --> R[Cloud-reachable TARGET_URL in remote mode] B --> F[JSON verification report] C --> F D --> F ``` The individual Playwright and Puppeteer demos select `BROWSER_WS_ENDPOINT` when present. Otherwise they launch a temporary local Chrome profile with a randomly assigned debugging port. `npm test` deliberately exercises local mode only. ## Quick start Requirements: - Node.js 22.12 or newer - Chrome or Chromium ```bash npm install npm test ``` The test writes `artifacts/latest-run.json` and exits non-zero on any failed assertion. Generated artifacts and endpoints are deliberately excluded from version control. If Chrome is installed in a non-standard location: ```bash CHROME_PATH=/path/to/chrome npm test ``` ## Run against an authorized cloud browser Most CDP-compatible providers return a `ws://` or `wss://` connection URL. Supply it at runtime rather than committing it. The remote browser must be able to reach `TARGET_URL`; the default is the neutral `https://example.com/` page. ```bash BROWSER_WS_ENDPOINT='wss://provider.example/session?token=REDACTED' \ TARGET_URL='https://example.com/' \ npm run demo:playwright BROWSER_WS_ENDPOINT='wss://provider.example/session?token=REDACTED' \ TARGET_URL='https://example.com/' \ npm run demo:puppeteer ``` The parallel recipe intentionally requires five separate endpoints: ```bash BROWSER_WS_ENDPOINTS='wss://…1,wss://…2,wss://…3,wss://…4,wss://…5' \ TARGET_URL='https://example.com/' \ npm run demo:parallel ``` Individual examples are also runnable: ```bash npm run demo:playwright npm run demo:puppeteer npm run demo:cold-restart npm run demo:parallel ``` Provider-specific profile creation should remain in a thin adapter before these scripts. That boundary keeps API authentication, profile lifecycle, and CDP automation independently testable. ## Expected verification shape ```json { "endpointSource": "local-chrome", "checks": [ { "client": "playwright", "title": "Cloud browser proof fixture" }, { "client": "puppeteer", "title": "Cloud browser proof fixture" }, { "client": "playwright", "isolatedProfiles": 5, "allValuesUnique": true }, { "client": "playwright", "coldRestartPersistence": true }, { "endpointRedaction": true, "protocols": ["ws", "wss", "http", "https"] } ] } ``` Timestamps and ephemeral local endpoint paths vary by run. ## Production hardening checklist Before adapting the sample to a production cloud-browser API: 1. Create profiles through the provider's documented API and use scoped, short-lived credentials. 2. Apply bounded timeouts, retry only idempotent setup calls, and record stable correlation IDs. 3. Cap concurrency and respect provider rate limits. 4. Treat screenshots, cookies, session URLs, and logs as sensitive artifacts. 5. Follow the provider's session lifecycle exactly. Do not open simultaneous sessions against the same profile unless its documentation explicitly allows that pattern. 6. Close each browser session in `finally` and verify provider-side cleanup. ## Responsible use Use these examples only on systems and accounts you are authorized to automate. They are not intended to bypass access controls, anti-bot protections, service terms, or privacy requirements. ## License MIT