-1

I am attempting to run headless Chrome on my MacBook, but when I run it according to the instructions here the Chrome app just opens normally, with its GUI. I am running:

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  -–headless \
  --disable-gpu \
  http://localhost:8080

This is a Node/Express app that I want to run inside a Docker container with headless Chrome. But I am running the above command by hand, in the terminal. And I just get the browser, as normal. I get the same result even if I leave out a specific url, opening at the default page.

Interestingly, if I pass -headless (one dash) instead of --headless (two dashes) the app opens in Chrome in another tab but the tab I see is at http://xn--headless-rn3d/. Whatever that is.

I have Chrome version 105.0.5195.125. MacOS Catalina 10.15.7. What am I doing wrong? Am I misunderstanding how headless mode is meant to work?

ChrisM
  • 2,128
  • 1
  • 23
  • 41

1 Answers1

1

OK, the following DID work:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --dump-dom http://localhost:8080

The above escapes the space in the path, rather than putting the entire thing in quotes. I was able to dump the HTML of my app to stdout with the --dump-dom flag. The Chrome icon appears briefly in the dock, then disappears. It never appears in the Activity Monitor though.

ChrisM
  • 2,128
  • 1
  • 23
  • 41