Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Web Browsers»Chrome»How To Use Google Chrome Headless Features

    How To Use Google Chrome Headless Features

    RahulBy RahulJune 9, 20172 Mins ReadUpdated:June 9, 2017

    Google Chrome latest version released with a new useful feature Headless Chrome. The headless Chrome is useful for browser automation. You can capture screenshots of any web page using the command line as well as programming language without starting Chrome GUI. It also supports to print the web page DOM and create a pdf of the web page. This tutorial will help you Use Google Chrome Headless Features on Linux command line.

    • How to Install or Upgrade Google Chrome in Ubuntu & LinuxMint
    • How to Install Google Chrome in CentOS/RHEL & Fedora

    1. Starting Headless Chrome

    Open the system console and start Google Chrome headless more using --headless command line option.

    $ google-chrome --headless http://www.example.com
    

    This headless mode also supports the remote debugging option to check what’s happening. You can access the system on specified port in any other browser and check what is rendering there. Start the debugging with the following command on specified port:

    $ google-chrome --headless  --remote-debugging-port=9222 https://google.com
    

    Now visit http://localhost:9222 in another web browser.

    The headless Chrome also has many other useful features like printing the DOM, capture screenshot or create pdf of any web page through the command line.

    2. Capture Webpage Screenshot

    You can use --screenshot option to capture screenshot of any web page. The output screenshot will be saved in current directory. For more details visit here.

    $ goolge-chrome --headless --disable-gpu --screenshot http://www.example.com/
    

    3. Create Webpage PDF

    You can use --print-to-pdf option to create PDF of any web page. The output pdf file will be saved in current directory. For more details visit here.

    $ google-chrome --headless --disable-gpu --print-to-pdf http://www.example.com/
    

    4. Print the Webpage DOM

    You can use --dump-dom flag to print document.body.innerHTML to standard output.
    The –dump-dom flag prints document.body.innerHTML to stdout:

    $ google-chrome --headless --disable-gpu --dump-dom http://www.example.com/
    

    Reference: visit following link to know more details about headless Chrome.

    https://developers.google.com/web/updates/2017/04/headless-chrome

    Google Chrome Headless headless chrome
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Create PDF of Webpage Using Google Chrome Headless
    Next Article How to Upgrade Fedora 25 to Fedora 26 Using DNF

    Related Posts

    How to Setup Selenium with ChromeDriver on Ubuntu 20.04 & 18.04

    Updated:October 5, 20214 Mins Read

    How to Capture Screenshot of Webpage Using Google Chrome

    Updated:April 24, 20191 Min Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.