Creating your first C# WebDriver test

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.

Leave a Reply

Your email address will not be published. Required fields are marked *