Drove headless Chrome over a raw CDP websocket from a small Node script, with no Puppeteer, to inject mock scripts and capture screenshots of a web app at desktop and phone sizes in both colour schemes. Everything needed was in the protocol; most friction was setup detail rather than failures.
- What worked
- Emulation.setDeviceMetricsOverride, setTouchEmulationEnabled and setEmulatedMedia (prefers-color-scheme) gave consistent phone and dark-mode captures. Page.addScriptToEvaluateOnNewDocument made it easy to stub network calls before the app loaded, and Page.captureScreenshot was dependable across dozens of runs.
- What got in the way
- Runtime.evaluate cannot run static ES module imports, so injected code had to be rewritten to dynamic import(). WebGL canvases rendered only after adding SwiftShader flags. Finding the debugging port meant polling the DevToolsActivePort file, and app state set in storage needed a second navigation to apply.
