Is your JUnit Assert class now deprecated? Well here’s how to fix it. JUnit have moved things around, and as a result the Assert class is now in a different location as and from JUnit 4.11

But fear not, rectifying this is a simple one-liner. Simply change your import statement from [code]import junit.framework.Assert; [/code] to this: [code] import org.junit.Assert; [/code]


When I started researching about Maven (What is it? Why do I need it? What does it do?) I came across a number of webpages that said that Maven came pre-installed on older version Macs. I have Mavericks on my iMac so I wasnt included in the group that came pre-installed with Maven. There are a set of instructions on the Apache Maven download page ( and a useful YouTube video following these instructions (from Evil Tester Videos, displayed below after the jump.).

Essentially the commands to enter are as follows:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/libexec/java_home
export PATH=${JAVA_HOME}/bin:$PATH

The only problem is these instructions create the environment variables needed for the current session only, they dont tell you how to make these changes permanent. If you reboot or even opena new Terminal window these changes will be lost. These changes must be written to a profile file. There a number of ways to name your profile file and these inclde “.profile”, “.bash-profile” and “.bashrc”. The files that begin with a dot are hidden system files. On a number of webapges the instructions for this step were along the lines of “add these to your .profile” etc. with no indication of how to add the commands to the secret hidden system file. You cant open it with apps like Sublime Text as it cant see the file. (it is hidden after all). A few more sites recommended using vi or emacs. I haven’t used vi or emacs in over 15 years and I wasnt too fond of them then, I certainly wasnt going to reacquaint myself with their unintuitive interfaces if I could help it.

Finally I found the simple answer:
[code]open .profile[/code]
Type that into the command line (from your home directory) and it will open the .profile file in your default application, which in my case is TextEditor. I added the above commands to the .profile file and saved it.

But Maven still wasn’t working. the JAVA_HOME variable wasn’t correct. I searched for and found the solution here. I updated the .profile with this and finally, Maven was working! Here are the fixed commands to add to your .profile:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH

View Details

This post will outline the basic structure of how to setup your C# NUnit test. First of all here is the code of the basic empty C# NUnit test file. I’ll explain all of the different parts below.
namespace MyWebDriverTest
public class Class1
public void TestCase01()


The two attributes [TestFixture] and [Test] are used by the NUnit Framework to indicate that there are tests to be executed. The [TestFixture] attributes is used by NUnit to indicate that the class contains test code. This class must be public and must also have a default constructor. The [Test] attribute indicates that the method is a test method. Test methods have to return a void and also must have no parameters.

Everything else is standard C# code for defining a class and a method.

This is the basic setup for a C# NUnit WebDriver test, and we will use this a s starting point for more in-depth tests in later posts.

As well as adding a reference to the project for Selenium WebDriver and NUnit, you must also add a “using” statement for the sections you are going to use in your test. A good start is to add the following using statements to your file:
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using NUnit.Framework;

Note: If you have more than one CS file in your project, you will need a using statement(s) for each file as required.

This may seem as common sense to the more seasoned programmer but for those starting off at the beginning it is a useful reminder. In the example above I have added a using statement for the standard Selenium WebDriver and NUnit classes and also for the Firefox browser. There are many other possibilities, but I will cover those as we need them.

This screenshot shows where the using statements are usually placed in a C# file:
Using Statements

Well a lot of angles covered anyway. As I have a Mac at home and a Win8 PC in work I will be posting examples and tips from both setups. Hopefully it will be a fairly balanced approach. In work I’ll be using WebDriver with the C# programming language, Visual Studio 2013 and NUnit. From my Home setup I will be using Java programming language and the JUnit test framework to write the WebDriver tests, but I am so far undecided on the IDE and build process. For IDE’s Eclipse and NetBeans are free and Intellij is a paid-for application. And the build process can use Maven or Ant. From what I have read online it appears that Maven is the easier one to use to get up and running so I will start with that.

So far I have found the beginning process a lot easier with the C# Visual Studio NUnit approach than with the Java based approach. I think the biggest help for this was my access to Pluralsight training videos, which luckily for me, the trainers all used C#, Visual Studio and NUNit for their test examples in the training courses. I have yet to find a similar resource from the world of Java/JUnit/etc which is part of the reason for writing this blog.

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.

I use Microsoft Visual Studio 2013 to create my C# WebDriver tests. If you do not have this application then you can download Visual Studio Express from here. I think the most suitable option for our use is the “Express 2013 for Windows Desktop” version.

Select File > New > Project from the menu and you should see a dialog similar to this one:
Create New Project

Select Visual C# from the Installed Templates on the left and then select Class Library from the list in the center. Choose a name for your project and select a location to save it at the bottom of the dialog.

The next step is to add references to your project for Selenium WebDriver and NUnit. You could add these references by directly adding the dll’s but I will accomplish this by using the NuGet Packages which is much easier. The first step is to open the NuGet Packages dialog. In the Solution Explorer, right click on References and select “Manage NuGet Packages…”
Manage NuGet Packages

The next step is to add the references for Selenium WebDriver. To find the Selenium packages, search for “selenium” in the search box in the top right hand side of the dialog:
Add WebDriver References

Followed by a reference for NUnit (again, search for “nunit”):
Add Reference for NUnit

Once these references have been added, they should be displayed in the References section in the Solution Explorer like this:
Refernces have been added

At this stage we are now ready to start writting our C# code for our test.

Deciding to write tests with WebDriver is only half the battle, you still need to pick a programming language, and possibly a test framework also. Most of the examples that I will be posting will be using C# and NUnit, but for the most part it should still be readable and easy to transfer to your chosen flavour. Many people use the Java programming language and JUnit or TestNG as the test framework.

But the choice is up to you, pick a flavour that you are comfortable with and run with it!

The reason I am starting this blog is to provide information for people who are new to WebDriver. When I started writing tests with WebDriver I found it very difficult to find information for beginners. Just the basics to begin with, how to get a test up and running before adding any of the fancy stuff.

There are plenty of resources out there who advanced practitioners who know what they are doing, but I found very little for those who are starting off at the beginning.

Hopefully this site will rectify that situation and I also hope that you find it a useful resource.