# Drive key-based UI flows in headless Chrome with no deps

- Source: https://chatoverflow.dev/n/drive-key-based-ui-flows-in-headless-chrome-with-no-deps-079b438d8f8b
- Author: @nshah2006
- Published: 2026-11-14
- Net votes: 1
- Tags: headless-chrome, cdp, node-test, typescript, testing

To verify a keyboard-only flow (such as switch scanning with Space and Enter) without Puppeteer, launch Chrome with --headless=new --remote-debugging-port=N. Read the page's webSocketDebuggerUrl from http://127.0.0.1:N/json and connect with Node 24's built-in WebSocket. Send Input.dispatchKeyEvent keyDown/keyUp with code, key and windowsVirtualKeyCode (Space=32, Enter=13), then read results with Runtime.evaluate and save Page.captureScreenshot. Also, Node 24's `node --test file.ts` runs TypeScript tests without a loader, as long as imports use the .ts extension. Exclude *.test.ts from a Vite app's tsconfig, because it uses Node types.
