TransWikia.com

Unable to use --screenshot or --print-to-pdf flags using headless mode of Chromium on Ubuntu desktop

Super User Asked by vgalin on January 28, 2021

I am using the headless version of Chrome and Chromium to take screenshots of given pages.
It works fine on Windows and Ubuntu server, but not on an Ubuntu Desktop VM.

I get the error "Open multiple tabs is only supported when remote debugging is enabled" on Ubuntu Desktop when I try to take a screenshot (--screenshot flag) or to generate a PDF file (--print-to-pdf flag).

I could enable remote debugging with the --remote-debugging-port flag, but when it is enabled, you can not use the --screenshot flag or the --print-to-pdf flag.

Details

On windows

Version :
Google Chrome Version 84.0.4147.125

Command used :
> start chrome --headless --screenshot=%CD%example_sh.png https://example.com/

Note: you have to give a path to the screenshot on windows or else it will not create the file, this is why I added %CD% on Windows only. But this is not the issue here.

Command output :
None

File generated :
Yes

On Ubuntu Server

Version :

$ chromium-browser --version
Chromium 84.0.4147.105 Built on Ubuntu , running on Ubuntu 18.04

Command used :
$ chromium-browser --headless --screenshot=example_sh.png https://example.com/

Command output :
[0812/102830.971006:INFO:headless_shell.cc(615)] Written to file example_sh.png.

File generated :
Yes

On Ubuntu Desktop

Version :

$ chromium-browser --version
Chromium 84.0.4147.105 snap

Command used :
$ chromium-browser --headless --screenshot=example_sh.png https://example.com/

Command output :
[0812/123941.367535:ERROR:headless_shell.cc(174)] Open multiple tabs is only supported when remote debugging is enabled.

File generated :
No

2 Answers

An answer has been given for the same question on SO : https://stackoverflow.com/a/63514185/12182226

Basically, instead of the chromium-browser or chromium command, you have to use the value of chromium's Executable Path shown in the chrome://version page. For instance, /snap/chromium/1260/usr/lib/chromium-browser/chrome.

To take a screenshot:
/snap/chromium/1260/usr/lib/chromium-browser/chrome --headless --screenshot=example_sh.png https://example.com/

Correct answer by vgalin on January 28, 2021

The problem is related to the snap version of Chromium on your desktop VM. Replace it with the same .deb package used on your server and everything should just work as expected.

Answered by Markus Ueberall on January 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP