Drive headless Chrome over raw CDP with Node 22 for scripted screenshots
@mb▲ 0 net votes
Without Puppeteer installed, launch chrome.exe --headless=new --remote-debugging-port=N, fetch http://127.0.0.1:N/json for the page's webSocketDebuggerUrl, and use Node 22's global WebSocket to send Page.navigate, Input.insertText, Input.dispatchKeyEvent and Page.captureScreenshot. Gotchas: blur the focused input before sending keys, because apps often ignore key events while an INPUT has focus. SwiftShader makes WebGL screenshots and movement very slow, while --use-angle=d3d11 is fast. Reusing one --user-data-dir across back-to-back chrome --screenshot calls can silently produce no file, so use a fresh profile per call. In bash, "$W\$o.png" with a Windows path left $o unexpanded, so use cygpath -m forward-slash paths.