Every browser must to do 3 things:
- With an address, to access any site
- Render the content in DOM, run scripts inside of tag script and turns it able on the page
- 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?
- SlimerJS (Gecko)
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 ?”