Selenium Webdriver is a browser automation tool, widely used to implement functional and acceptance tests. It supports a variety of browsers, including headless ones like PhantomJS. But how easy is it to setup a project and run Selenium?
We’ll discover in this article. I prepared a full working project that you can clone from Github: selenium-windows-quickstart.

Java binding

Selenium has “bindings” for many programming languages: Python, Java, Ruby, C# and Javascript (Node). What are those “bindings”? They are language-specific client drivers, which let you control the browser from your language of choice.
I will introduce binding for Java language.


Firefox is the easiest browser to set up. After installing it, the following example code will launch Firefox and open Selenium website:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

WebDriver driver = new FirefoxDriver();

There is nothing else to do, Selenium will take care of everything.


Chrome requires a little bit of extra work. After installing the browser itself, you need to download a small executable called ChromeDriver. This is a bridge between Selenium java driver and Chrome itself.
Download and unzip the latest version in a folder on your hard drive. Next, you have to tell Selenium driver where the ChromeDriver is located by setting Java system property to ChromeDriver’s path.

import org.openqa.selenium.WebDriver;

System.getProperties().put("", "c:\\Users\\you\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

Selenium will start the ChromeDriver, connect to it and then control Chrome browser. The can also be set in command line using\\Users\\you\\chromedriver.exe when invoking Java. In my quickstart project I set it in pom.xml and let Maven pass it to JVM.


The procedure for Opera is the same as Chrome: download the OperaDriver and unzip in the same folder as ChromeDriver. Set the webdriver.opera.driver Java system property using your preferred way and you’re ready to go.

import org.openqa.selenium.opera.OperaDriver;

System.getProperties().put("webdriver.opera.driver", "c:\\Users\\you\\operadriver.exe");
WebDriver driver = new OperaDriver();

Internet Explorer

Internet Explorer is no different from the other browsers this time. Download and unzip its IEDriverServer, set, instantiate the InternetExplorerDriver in your code.


System.getProperties().put("", "c:\\Users\\you\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();


HtmlUnit is a special kind of browser: it is “headless”, meaning that it uses no screen. It’s purspose is to be runned on machines that have no GUI (like most Linux servers) or no users logged in.
It has some limitations on Javascript, I advise against using it on Javascript heavy sites.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

WebDriver driver = new HtmlUnitDriver(true);


Setting up Selenium with Java binding requires only a few lines of code. You can clone this selenium-windows-quickstart project and start driving your browser of choice!
Don’t like Java? Python quickstart is coming soon! =)