简体   繁体   中英

Headless Chrome opening as normal with GUI (MacOS)

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM