Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Browsers»Chrome»How To Use Google Chrome Headless Features

    How To Use Google Chrome Headless Features

    By RahulJune 9, 20172 Mins Read

    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.

    Advertisement
    • 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

    Related Posts

    How to Setup Selenium with ChromeDriver on Ubuntu 22.04, 20.04 & 18.04

    capture screenshot google chrome

    How to Capture Screenshot of Webpage Using Google Chrome

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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