The “Headless Browser” is a web browser without a graphical user interface. In other words, it is a browser that accesses web pages, but it does not show them to anyone (these are executed in memory). It can understand web pages as a common browser would and can interact with web pages in the same way. Usually, we see how our scripts run a browser (Internet Explorer, Firefox, Chrome, etc.) and execute different actions on the screen; in the case of Headless Browsers, the execution behaves in a very similar way, except that we do not see the actions on the screen. The use of this type of browser in automated tests is located between the tests of UI and the Services since they do not involve the UI, but it tests its functionality.
What can you do when projects get complicated by external or internal issues? Check out this Intraway insider’s story.
What is a headless browser used for?
- Test automation on web pages.
- Capture screenshots (compare screenshots, validate the responsive design, validate CSS values).
- Extract data from web pages (web scraping ).
- Download contents of web pages.
- Perform DDoS attacks on websites.
- Increase ad impressions on websites.
- Automate brute force attacks for login pages, using performing repeated – automated – login attempts.
When Should You Use a Headless Browser?
- When quick feedback of the tests is required. With the execution of tests in UI, for each execution, it is necessary that a screen browser is run and this takes a long time (some take more than 10 seconds to open depending on the computer).
- When you need an automated script that navigates through the different pages of the system under test and collects data from them. In this case, there is no need to open a browser since all you need is to access the pages.
Advantages of Headless Browsers
- Test results are obtained much faster. Running in memory does not require all the preparation that happens when you open a graphical browser, significantly reducing the execution time of the scripts.
- Screenshots can be taken as in a standard automated test.
- Relatively easy to configure.
- The tests that run against the UI can be adapted to run headless.
- Selenium Webdriver (a web automation framework that allows you to test cases on different browsers) has the ghostDriver, which makes it easier to apply if we work with WebDriver, similar to ChromeDriver (a standalone server that implements the WebDriver connection protocol for Chrome).
Disadvantages of Headless Browsers
- It is not a real browser and it is not representative of real users. The end users of the website will not use headless browsers.
- It does not replace the automated UI tests, but complements them and seeks to provide faster feedback about the status of an application under test.
- The implementation of the tests becomes more complicated when accessing the HTML DOM elements.
Which Are The Most Used Headless Browsers?
Although we should keep in mind that a normal user wouldn’t probably use a headless browser, they are very fast. When we need a quick response to our tests, it is undoubtedly the best option.
Check out the second part of our blog post Hacking Your Telecoms Systems, an Intraway employee shares how a complex project situation was successfully resolved.