## Usage via the DevTools remote debugging protocol
-1. Start a normal Chrome binary with the `--headless` command line flag
-(Linux-only for now):
+1. Start a normal Chrome binary with the `--headless` command line flag:
+```sh
+$ chrome --headless --remote-debugging-port=9222 https://chromium.org/
```
-$ chrome --headless --remote-debugging-port=9222 https://chromium.org
-```
-
-Currently you'll also need to use `--disable-gpu` to avoid an error from a
-missing Mesa library.
-2. Navigate to `http://localhost:9222` in another browser to open the
+2. Navigate to `http://localhost:9222/` in another browser to open the
[DevTools](https://developer.chrome.com/devtools) interface or use a tool such
as [Selenium](http://www.seleniumhq.org/) to drive the headless browser.
For example, the [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface)
Node.js package can be used to extract a page's DOM like this:
-```
+```js
const CDP = require('chrome-remote-interface');
CDP((client) => {
API. It loads a web page and outputs the resulting DOM. To run it, first
initialize a headless build configuration:
-```
+```sh
$ mkdir -p out/Debug
$ echo 'import("//build/args/headless.gn")' > out/Debug/args.gn
$ gn gen out/Debug
Then build the example:
-```
+```sh
$ ninja -C out/Debug headless_example
```
After the build completes, the example can be run with the following command:
-```
-$ out/Debug/headless_example https://www.google.com
+```sh
+$ out/Debug/headless_example https://www.google.com/
```
[Headless Shell](https://cs.chromium.org/chromium/src/headless/app/headless_shell.cc)
To do this, start the application with an argument specifying the debugging
port:
-```
+```sh
$ ninja -C out/Debug headless_shell
-$ out/Debug/headless_shell --remote-debugging-port=9222 https://youtube.com
+$ out/Debug/headless_shell --remote-debugging-port=9222 https://youtube.com/
```
-Then navigate to `http://localhost:9222` with your browser.
+Then navigate to `http://localhost:9222/` with your browser.
+
+As of M118, precompiled `headless_shell` binaries are available for download
+under the name `chrome-headless-shell` via [Chrome for Testing
+infrastructure](https://googlechromelabs.github.io/chrome-for-testing/).
## Embedder API