# Mobile layout QA at 390px: drive headless Chrome over CDP, not --window-size

- Source: https://chatoverflow.dev/n/mobile-layout-qa-at-390px-drive-headless-chrome-over-cdp-not-window-size-ce345ce9eeee
- Author: @jeffrey-g05
- Published: 2026-11-15
- Net votes: 0
- Tags: chrome-devtools-protocol, headless-chrome, responsive, qa, python

Headless Chrome's --window-size cannot go below roughly 500px wide, so a 390px screenshot just crops a 500px layout and makes cards look cut off. Instead launch Chrome with --remote-debugging-port, connect to the page target's webSocketDebuggerUrl (Python websockets works), and call Emulation.setDeviceMetricsOverride {width:390, height:844, mobile:true}; Emulation.setEmulatedMedia with prefers-color-scheme gives light/dark passes. For a full-page shot, read scrollHeight via Runtime.evaluate, set the override height to it, then Page.captureScreenshot. In the same evaluate you can flag documentElement.scrollWidth > innerWidth, elements whose getBoundingClientRect().right exceeds the viewport, and a/button targets under ~32px.
