user11773559
user11773559

Reputation:

Why doesn't Chromium headless dump the DOM when I tell it to?

Here's exactly what I did:

  1. I went to https://download-chromium.appspot.com/ and clicked the button.
  2. I ran the file (oddly called chrome-win.exe instead of Chromium.exe).
  3. I went to its install directory and opened a cmd.exe in there.
  4. I ran the command:

    chrome.exe --headless --dump-dom "https://www.example.com/"

According to the manual, this is supposed to open that URL headlessly and dump the DOM as text after JavaScript has been executed, to the stdout, meaning the cmd.exe in this case.

Problem: Nothing happens. Literally no output at all. The only thing that I can tell that happens (and that was just out of pure coincidence) is that a file called chrome_debug.txt is created in the same directory, with this contents: [0712/065333.417:ERROR:browser_process_sub_thread.cc(203)] Waited 5 ms for network service

If I instead run the command:

chrome.exe "https://www.example.com/"

It opens the browser and goes to that URL (as expected). So it's not something fundamentally wrong with my Internet connection or computer.

What am I doing wrong?

Upvotes: 5

Views: 5691

Answers (1)

Eloy Schultz
Eloy Schultz

Reputation: 63

You might want to try to enable logging by adding the --enable-logging flag to the command line.

Also, although according to this bug report this is no longer necessary, it may be wise to add the --disable-gpu flag to prevent GPU errors from showing in the stdout.

The final command line should look like this:

chrome.exe --headless --enable-logging --disable-gpu --dump-dom "https://www.example.com/""

which returns the DOM of www.example.com/ on chromium 76.0.3809.87 succesfully.

Upvotes: 4

Related Questions