What is headless browser ?

Every browser must to do 3 things:

  1. With an address, to access any site
  2. Render the content in DOM, run scripts inside of tag script and turns it able on the page
  3. Render the DOM in a visual content

A browser that do only the first item is called of  “text-based”. A browser that surround the 3 itens is the browsers that we know nowadays. A headless browser surround both firsts itens.

So,  headless browser is a browser that don’t have graphical interface, means: We don’t see the content of the page in our screen, but the browser runs any action on the URL.

What is its function?

Two things: As crawler and as a browser that do faster tests. The rising use of headless browsers is the capacity of run tests a faster way than a browser with graphical interface.

It turns more faster to don’t need load a lot of visual contents, as css styles on elements and load of images.

Think in a Continuous integration, each behaviour(commit, time, version…) a system of CI has to process (compile, unit tests with/or not integration, deploy, acceptance tests). In this process run the tests daily in a environment of CI will spend a lot of time to give us a feedback that we need.

What the people used to do is separate in few parts the most important scripts (smoke, sanity) with known tools (Selenium, Watir, Robot Framework), but these tests still spend a precious time on the execution because of the visual contents that they need.

Other people create scripts or just update them to execute on headless browser. This give to us a huge gain on execution and give to us a more faster feedback.

What are the headless browsers that we can use?

There are a lot of headless browsers on the market and the most part of them (and the best) are open source. They are developed on WebKit and Javascript. The most popular headless browsers:

  • PhantomJS
  • CasperJS
  • SlimerJS (Gecko)
  • HtmlUnit
  • ZombieJS

And Selenium/WebDriver can run tests in the most popular headless browsers:

  • HtmlUnit through of HtmlUnitDriver
  • PhantomJS through of GhostDriver

If you have any doubt or suggestion, just write below !

Thank you again guys 🙂

2 thoughts on “What is headless browser ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.