There are a couple of setup steps required before you can run a Java JUnit WebDriver test on your Mac. As always there are a number of different ways this can be done but I will outline one that has worked well for me. I’ll just outline the steps involved first and then go through each of them in a little more detail after:

  1. Download and install “Eclipse IDE for Java EE Developers”
  2. Download and install Java
  3. Download JUnit
  4. Download and install Apache Ant
  5. Download Selenium WebDriver
  6. Create Project and lib folders
  7. Configure the build path (in Eclipse)

(1) Download and install “Eclipse IDE for Java EE Developers”

Go to and click on the downloads link. From this page download and install “Eclipse IDE for Java EE Developers”
Download Eclipse for Java EE Developers

(2) Download and install Java

  • Setup $JAVAHOME
  • Setup $CLASSPATH
  • Verify your Java installation by using [code]java -version[/code]

(3) Download JUnit

Download the following JAR files from :

  • JUnit.jar
  • hamcrest.jar

(4) Download and install Apache Ant

Download and install Apache Ant. For further details on this please see my earlier post on Installing Ant. You can also find a link to Apache Ant page from my Resources page.
Don’t forget to verify your installation with [code]ant -version[/code]

(5) Download Selenium WebDriver

Download the following two JAR file from Selenium HQ Downloads: (see link in the Resources page.)

  • WebDriver jar file
  • Java Bindings jar file

(6) Create Project and lib folders

Eclipse uses a folder called a “workspace” in which all of its projects are located. On first opening Eclipse you will be prompted to specify a default workspace.

Inside this folder create a folder for your project. Inside this project folder create a “lib” folder and add the 4 JAR files you have downloaded earlier. Note you will have to unzip the Java Bindings zip file to get the seelnium-java JAR file.

(7) Configure the build path (in Eclipse)

Right click on the project name, and select Build Path > Configure Build Path. When the dialog is displayed, click on the button for Add External JARs.
From here select the 4 JAR files (hamcrest, junit, selenium-java & selenium-server-standalone) we have added to the /Workspace/Project/lib folder in the previous step.

And that concludes the basic setup required to run Java/JUnit Selenium WebDriver tests on your Mac. You are now ready to create and run a Selenium WebDriver Java test using the JUnit framework. In the next post I will create a simple test and execute it from within Eclipse and also from the Command Line/Terminal using Ant.

I found this useful answer on StackExchange on how to install Apache Ant on a Mac. Earlier versions of OSX came with Ant preinstalled but not so on my installation of Mavericks. Before we do anything we need to download the Ant files from The code snippet below assumes that you download the .tar.gz version, but you can work around it if you have downloaded one of the other versions and know how to extract the archive. Copy and paste the commands below into your terminal session (I did them one by one. Also the lines beginning with a # are comments).

# Let’s get into your downloads folder.
cd ~/Downloads/

# Extract the folder (If you have already extracted the downloaded archive, skip this step) /
tar -xvzf apache-ant-1.8.1-bin.tar.gz

# Ensure that /usr/local exists
sudo mkdir -p /usr/local

# Copy it into /usr/local
sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant

# Add the new version of Ant to current terminal session
export PATH=/usr/local/apache-ant/bin:”$PATH”

# Add the new version of Ant to future terminal sessions
echo ‘export PATH=/usr/local/apache-ant/bin:”$PATH”‘ >> ~/.profile

# Demonstrate new version of ant
ant -version

The last line is just to verify that you have successfully installed Apache Ant. And that’s it, you have successfully installed Apache Ant on your Mac.