Run Chrome without chrome, it brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line.
A headless browser is a great tool for automated testing and server environments where you don’t need a visible UI shell.
The easiest way to get started with headless mode is to open the Chrome binary from the command line. If you’ve got Chrome 59+ installed, start Chrome with the
-- headless flag:
chrome should point to your installation of Chrome.
In some cases, you may not need to programmatically script Headless Chrome. There are some useful command line flags to perform common tasks.
--dump-dom flag prints
document.body.innerHTML to stdout:
chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com/
--print-to-pdf flag creates a PDF of the page
chrome --headless --disable-gpu --print-to-pdf https://chromestatus.com/
To capture a screenshot of a page, use the
chrome --headless --disable-gpu --screenshot https://chromestatus.com/
--repl flag runs Headless in a mode where you can evaluate JS expression in the browser, right from the command line:
chrome --headless --disable-gpu --repl https://chromestatus.com/