So you can use that to kill the process, if you want to restart it or just be rid of it.
Note: Your terminal will now be occupied by running that chrome browser in headless mode, if you want to detach it and keep it in the background, append a & to the command like so: google-chrome -headless -hide-scrollbars -remote-debugging-port=9222 -disable-gpu &Īnother tip, if you want to know the process ID of your chrome headless browser, append & echo $!, which will output the process ID of what you just started: google-chrome -headless -hide-scrollbars -remote-debugging-port=9222 -disable-gpu & echo $! To start the headless chrome browser, simply run: google-chrome -headless -hide-scrollbars -remote-debugging-port=9222 -disable-gpu Ubuntu apt-get install google-chrome-stable.Getting / Starting Chrome HeadlessĪssuming you want to run this on a linux server, after installing Google Chrome via apt/pacman/yum, run: google-chrome -versionĮxpected output: Google Chrome. The example code makes use of async and await, so please be on Node.js 7.8+.Īs always I recommend NVM for installing different versions of Node. There’s a ton of services for this out there, but if you have some kind of edge case or simply just need a better way of taking screenshots, please read on. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:30456) DeprecationWarning: Unhandled promise rejections are deprecated. Right-click the node and click 'Capture node screenshot' in the context menu. Next, select the HTML node you want to take a screenshot of in the Elements tab. Update: A Chrome update actually broke the code for full page screenshots using forceViewport, the code samples have been updated to support the change.įull error message: (node:30456) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Emulation.forceViewport is not a function Chrome/Edge version 86 introduced an easier way to capture node screenshots: Open DevTools by pressing F12, ctrl + shift + i, or by opening the menu > More Tools > Developer tools. If you’re brave, you can use Windows too ?
#Taking screenshot google chrome mac os
This post will cover installation and running the script on either Mac OS or Linux.
#Taking screenshot google chrome how to
A returning subject on this blog, how to automate device screenshots with Node.js and Chrome.