What is Headless Chrome?

Headless Chrome is like running a chrome browser without UI (browser) i.e., it is running in a headless environment, which is very useful for running automated tests. So, what does headless Chrome unlock for us? One of the most exciting things is the ability to test the latest and greatest web platform features like ES6 modules, service workers, and streams. With headless chrome, you can write apps and test those apps with up-to-date rendering. The other thing that it unlocks is these awesome functionalities like network throttling, device emulation, and code coverage. With headless chrome, you can perform tests without even writing a line of code, isn’t that cool! You can just execute them through the command line. Below are some of the popularly used flags. Note – this is different from the Chromium browser.

Chromium Installation on Ubuntu

Step 1: Update Ubuntu

In the beginning, update the packages in Ubuntu.

Step 2: Install Dependencies

Install these dependencies which are required for the installation. There might be cases where few dependencies would be missing to install chrome. So, run the command below, it will install all the missing dependencies required to install chromium.

Step 3: Download Chrome

Download the google chrome stable package for the Ubuntu system.

Step 4: Install Chrome

Install the stable package.

Step 5: Check Chrome Version

To confirm the installation has finished successfully, check the Google Chrome version.

Optional: Run Chrome Headless

Let me show you an example of running chrome in headless mode. I will run chrome in headless mode, and all the content of https://gf.dev/ will be saved as a pdf file. You can see a file output.pdf Next, I will show you how to do the same setup in the CentOS system.

Chromium Installation on CentOS

Step 1: Update CentOS

Update the CentOS system with the below command.

Step 2: Create Chrome Repository

Add google chrome repository to the system. Create a file google-chrome.repo inside /etc/yum.repos.d/ and add the details below.

Step 3: Install Chrome

Run the yum command below to install the google chrome on the CentOS system.

Step 4: Check Chrome Version

To confirm the installation has finished successfully, check the google chrome version.

Optional: Run Chrome Headless

Let me show you an example of running chrome in headless mode on CentOS. I will take the example of capturing a screenshot. This command below will run chrome in headless mode, and all the content of https://www.chromestatus.com/ will be saved as a pdf file. The output.pdf file got created which has all the content of https://www.chromestatus.com/ That was all about how to install Chrome on Ubuntu & CentOS and run it in the headless mode.

How to Install Chromium on Ubuntu and CentOS  - 21How to Install Chromium on Ubuntu and CentOS  - 84How to Install Chromium on Ubuntu and CentOS  - 97How to Install Chromium on Ubuntu and CentOS  - 70How to Install Chromium on Ubuntu and CentOS  - 37How to Install Chromium on Ubuntu and CentOS  - 84How to Install Chromium on Ubuntu and CentOS  - 44How to Install Chromium on Ubuntu and CentOS  - 48How to Install Chromium on Ubuntu and CentOS  - 23How to Install Chromium on Ubuntu and CentOS  - 90How to Install Chromium on Ubuntu and CentOS  - 21How to Install Chromium on Ubuntu and CentOS  - 43How to Install Chromium on Ubuntu and CentOS  - 10How to Install Chromium on Ubuntu and CentOS  - 89How to Install Chromium on Ubuntu and CentOS  - 15How to Install Chromium on Ubuntu and CentOS  - 57How to Install Chromium on Ubuntu and CentOS  - 82How to Install Chromium on Ubuntu and CentOS  - 55How to Install Chromium on Ubuntu and CentOS  - 45How to Install Chromium on Ubuntu and CentOS  - 94How to Install Chromium on Ubuntu and CentOS  - 50How to Install Chromium on Ubuntu and CentOS  - 52How to Install Chromium on Ubuntu and CentOS  - 50