About Headless Browsers and Headless Testing
Posted By : Aditi Nahar | 31-Dec-2018
In this article, I will discuss Headless browsers, why to use them and when not to use them, what is Headless testing and its importance. And lastly an introduction and use of Headless Chrome tool.
Introduction
Headless Browsers are web browsers which don’t have a head or GUI (Graphical User Interface). This means a program runs at the backend to access the web pages but nothing is seen on the screen.
Why use Headless browsers?
- To run tests on headless systems like Linux operating system without GUI.
- To run tests parallelly on multiple browsers on a single machine.
- To utilize minimum resources as GUI is not there.
- Need to run the test just for data creation and not for actual testing.
When not to use these browsers?
- Where there is a need to visually observe the tests on the browser.
- As everything is running on backend and nothing is seen on the screen and UI is not a part of testing so it does not give the exact feedback of what users will actually experience on the website.
- Sometimes errors thrown by Headless browsers are not observed on real browsers.
Introduction to Headless testing and its importance
Headless testing is a method through which browser UI tests can be executed without the head, which implies that there is no browser GUI for running the tests. This is helpful in environments where running the tests does not require the GUI, for eg in a CI environment. With headless browsers, tests execution is fast in a real browser environment so it offers high performance.
What is Headless Chrome?
Headless Chrome is one of the tools which helps in Headless testing on Chrome browser. It can be used in the latest versions (59+) of Google Chrome. It makes it possible to interact with the websites without having a window on the screen.
To work with Headless Chrome, only a terminal and the latest version of Google Chrome is required.
chrome --headless --disable-
Let’s see some example of basic operations by Headless Chrome:
1. To create PDF of a page.
chrome --headless --disable-
<webpage URL>
The result to this will be a pdf file of webpage titled as output.pdf.
2. To capture a screenshot of a page.
chrome --headless --disable-
<webpage URL>
The result to this will be a screenshot of webpage titled as screenshot.png.
To take a screenshot of a custom size, --window-size flag needs to be added to the command.
chrome --headless --disable-
<webpage URL>
Hope this article will help you in dealing with Headless browsers and headless testing.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Aditi Nahar
Aditi is a certified QA Engineer with a strong command over management tool sets like JIRA and Trello, as well as QA tool sets for API and performance testing. She possesses excellent verbal and written communication skills and has gained valuable experience in management and leadership while collaborating with clients and large teams. Aditi's ability to apply creative thinking and problem-solving skills makes her adept at handling challenging business scenarios. Her proficiency in manual testing has proven instrumental in identifying issues and ensuring the functionality of applications across web, mobile, and TV platforms. She has made significant contributions to both internal and client projects, including Bits2Btc, AUS-BTC, EZBitex, ACL EAP, Scaffold, Iron Systems VRP, Oremus Zoho, and NOWCAST OTT.