10 HeadLess Browsers For Automated Testing

A headless browser is a piece of software that access webpages, but doesn’t show them to real users. It’s a web browser without a graphical user interface. They are often used to provide the content of  webpages to other programs, for instance, it could be used by a program to access a webpage and extract some information like how wide that page is, what font is used or what’s the coordinates of a specific element.

They are capable to executing JavaScript and AJAX that are usually not available in other testing techniques. The purposes of using headless browsers are –

  • Run automated tests
  • Scraping webpage data
  • Take screenshot of webpages
  • Automating interaction of webpages
  • Perform DDOS attack and increase banner impressions

We are listing all those browsers that provide complete or near-complete headless implementation, and simulate a browser environment.

10. Zombie.js

Zombie.js is a simulated browser environment for Node.js. It doesn’t render DOM and have limited support for DOM events. It provides a full-featured API to interact with page content, including pressing a submit button. The tool performs faster than full browsers, but is unable to correctly interpret most of the popular websites.

As far as involving resources is considered – retrieving scripts, XHR requests and HTML pages over HTTP and HTTPS, is done behind the scenes. Zombie inspects the history of retrieved resources, which is useful for troubleshooting errors related to resource loading.

9. X-Ray

X-Ray comes with an entirely composable API that gives you flexibility in how you scrap each webpage. The tool supports an array of objects, nested object structures, strings, pagination, crawler concurrency, strings delays, timeouts, throttles and pluggable drivers.

X-Ray becomes more powerful when users compose multiple instances together. In addition, it supports “collection of collections” allowing users to smartly select all items in all lists.

8. Erik

Erik is based on WebKit that helps you run functional tests in order to access and manipulate webpages using JavaScript. It is based on WebKit and HTML parser Kanna. The browser is known to support Swift language. On macOS 10.11 and iOS 9 (or later version), you must use HTTPS, because they do not like application to send or receive data insecurely.

7. AngleSharp

AngleSharp is a .NET library that allows you to parse angle bracket based hypertexts like SVG, HTML and MathML. The parser is developed as per W3C specification, and CSS can also be parsed. Moreover, the library focuses on standards compliance, interactivity and extensibility.

AngleSharp features useful abstractions (type helpers), fully-functional DOM, form submission, navigation, enhanced LINQ, and standards conform. It has been developed as PCL that supports a wide range of platforms, including .NET framework 4.5, Windows 8.1, Xamarin.Android/iOS, and Silverlight 5.

6. SlimerJS

With SlimerJS, you can manipulate a webpage with an external JavaScript, for example, you can open a webpage, click on the links, modify the content, and more. It is mostly used for functional testings, page automation, screen capture and network monitoring.

SlimerJS runs Gecko, the browser engine of Mozilla. It is not natively headless yet, but you can make it headless yourself with the used of xvfb under Linux.

5. Splash

Splash is a lightweight browser with an HTTP API, implemented in Python using QT and Twisted. It properly renders JavaScript webpages, and even interacts with them. You can extract information about requests and responses initiated by a page. The project is started at ScrapingHub in 2013, and partially funded by DARPA.

Using Splash, you can process multiple webpages in parallel, write Lua browsing scripts, get detailed rendering data in HAR format, turn off images, or use Adblock rules to make rendering faster, and develop Lua scripts in Splash-Jupyter Notebooks.

4. TrifleJS

TrifleJS is headless Internet Explorer scriptable browser that uses the V8 JavaScript engine for running scripted tests, Trident layout engine for rendering pages, and .NET WebBrowser object to control Internet Explorer.

Most of the API part is coded as a port of PhantomJS, which is perfect for automated testing. If you are familiar with phantom, then you already know how to use TrifleJS.
Since IE is losing market share continuously, the whole project will become useless if Microsoft decides to drop IE.

3. HtmlUnit

Originally written in Java, HtmlUnit uses the Rhino engine to provide AJAX and JavaScript support, along with partial rendering capability. It is commonly used for test automation of webpages, web scraping or downloading website content. It provides a high-level API, and you can configure it to simulate any browser.

HtmlUnit is capable enough to deal with basic HTTP authentication, automatic page redirection and HTTPS security. It lets Java test code to analyze returned pages either as XML DOM, text or as a collection of links, forms and tables. Moreover, the implementation speed of HtmlUnitDriver is faster as compared to other WebDriver.

2. PhantomJS

Developed by Ariya Hidaya, PhantomJS uses JavaScriptCore for running scripted tests and WebKit layout engine for rendering webpages. It has fast and native support for various web standards – CSS selector, SVG, DOM handling and Canvas.

PhantomJS an optional solution for headless webpage testing, screen capturing, page automation and network monitoring. It is often used as a way to automate attacks against websites, and it mimics legitimate user traffic and can complicate attack mitigation technologies.

Read: 25+ Cool Alternative Web Browsers You Didn’t Know of

1. Chrome

World’s most popular browser, Google Chrome, now supports headless environment (version 59 and above). It brings all modern web platform functionalities offered by Chromium and the Blink rendering Engine to the command line.

Read: What’s New in Google Chrome 59

Since there are some useful command line flags, you don’t need to programmatically script Headless Chrome. It can be developed as a library for embedding into a C++ application, which is similar to controlling the browser over a DevTools connection, but it offers more customization keys like for mojo services and networking.

The Embedder API allows you to add headless library into your app. It provides default implementation for low level adaption points like networking and the run loop. Moreover, with headless client API, you can drive the browser and interact with loaded web pages.

Leave a reply