Headless browser testing

Good afternoon peeps,

I’m always looking to further expand my knowledge to ensure that I take on board new approaches, should they prove to be more beneficial.

I have a couple of questions relating to headless browser testing so was hoping to lean on the good people who frequent this site who know about this area:

  1. In what circumstances would you use headless browser testing?
  2. Playing devil’s advocate, isn’t bypassing the UI dangerous for test automation in that we aren’t seeing the UI as the customer would use it? e.g. how it behaves in different circumstances
  3. Which tool provides a good introduction to headless browser testing? And are there any recommended tutorials people would recommend?

Thanks a lot


1 Like
  1. I use headless testing in my project where we are a web app that is only used internally (not public facing) and doesn’t require cross browser, so we are happy to run the automation suite using currently headless firefox (before we used phantomjs)
  2. You are not bypassing the UI, you are only not loading the UI as it runs (there are lots of articles on what it is… https://blog.logrocket.com/introduction-to-headless-browser-testing-44b82310b27c)
  3. I’ve used it with selenium with Java and C#. Now I’m using it in a project where we use ruby’s capybara.
    If you already have tests running through a browser, all you need to do is search on how to set your browser to run in headless mode (if it is chrome or firefox), the other option is to use something like phantomjs.

Brilliant, thanks Jose. I’ll read up on this so I can start looking at implementing it

Headless Testing:
Headless testing is execution of automated UI based test cases without launching browser. Test scripts are being executed but without initializing browser itself. Headless execution is not useful for functional testing but for automation testing its awesome.

Headless browser execution is faster than real browser:
Execution of test scripts is way faster than real browsers. This is one of the best pros for using headless browser testing. Because we are not starting browser UI to load CSS, Javascript. Hence, it saves time. Top Software testing Companies are using headless browser execution because sometimes it is faster 2 times to 15 times than the real browser.

Headless browser for Unit testing:
People working in Software testing services company are using headless browser execution for Unit test cases to save tremendous amount of time. You can simulate multiple browser versions on the same machine.

When Headless browser is not used:
Headless browser execution is not useful when people want to watch the test script execution.

Example of Headless browsers:
Google Chrome

Automation code to initialize the Headless chrome browser using Java/Selenium:
System.setProperty(“webdriver.chrome.driver”, chromeDriverPath);
ChromeOptions chromeOptions = new ChromeOptions();
ChromeDriver driver = new ChromeDriver(chromeOptions);

Also, Selenium supports headless testing using its class called HtmlUnitDriver. This class internally uses HtmlUnit headless browser.
Code to initialize HtmlUnitWebDriver with Java script support is as follows: [HtmlUnitDriver allows you to select the version of browser that you would like to run your tests on]
HtmlUnitDriver unitDriver = new HtmlUnitDriver();

Hope this information is very helpful for you.


Hi Andy.

I’m using headless testing daily.
I got my tests for UI in Robotframework and using Xvfb library for running it in headless mode.
Xvfb is a display server implementing the X11 display server protocol. (so Linux)
Usage is very simple. Then, I can run my tests in Jenkins pipelines.
Another tool could be Cypress which is running tests in headless mode by default on Linux - in Electron browser. No additional setup needed.