Does Selenium support headless browser testing?

The WebDriver API has support for HTMLUnit as the browser for your testing. Ruby people have been using Capybara for a while for their headless selenium testing so it is definitely doable.


you need not use PhantomJS as an alternative to Selenium. Selenium includes a PhantomJS webdriver class, which rides on the GhostDriver platform. Simply install the PhantomJS binary to your machine. in python, you can then use:

from selenium import webdriver
dr = webdriver.PhantomJS() 

and voila.


Headless browsers are a bad idea. They get you some testing, but nothing like what a real user will see, and they mask lots of problems that only real browsers encounter. You're infinitely better off using a "headed" browser (i.e., anything but HTMLUnit) on a headless environment (e.g., Windows, or Linux with XVFB).


I know this is a old post. Thought it will help others who are looking for an answer.

You can install a full blown firefox in any linux distribution using XVFB. This makes sure your testing is performed in a real browser. Once you have a headless setup, you can use webdriver of your choice to connect and run testing.