Sunday, May 19

How to setup C#,nUnit and selenium client drivers on VSExpress for Automated tests

Selenium can be used in conjunction with C# and Nunit to build robust automated test cases. This blog is one of the How to series on selenium-C# that help novice automation tester to learn and build automation test cases.
In this blog, I would be explaining the how to setup tools for Selenium web driver automation.
To build selenium webdriver automation test cases in C# and Nunit, you would require to setup

  1. IDE for C# - Download Visual studio express for Windows Desktop. This is free for 30 days and You must register to obtain a free product key for ongoing use after 30 day. Installation of this tool is pretty straight forward
  2. Nunit - Download NUnit and installation is pretty straight forward
  3. Selenium Dot net client drivers - Download it from selenium download website . The latest version at this time is found as shown below. The drivers are nothing but dll files which needs to referred when you build the test cases which is described later in this blog
Once the VS express is installed, open the tool and it will display the welcome page. To create a selenium test cases in C#, we need to use C# project of VSExpress. For that on file menu click new project and this open new project window. Open Unit test project under Visual C# and click OK This will open a class file as shown below
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject1
    public class UnitTest1
        public void TestMethod1()

This is basic test project template in C#. For this projects lets add the references and these include the Selenium web driver which you downloaded and the nUnit dll file from Nunit bin folder. To do this on VS express menu bar, click on project-> add reference. And using browse button browse to directory where you downloaded the selenium c# drivers. Within the directory you may have directory called net40( latest version at the time blog was written) and under this directory select all files and click Ok . Below is the DLL files that I have with current version of C# selenium client libraries.


Once this done we are now set to write automation test cases using Selenium web driver and C#. To Verify whether the selenium client reference libraries are added, try typing at the top “using OpenQA” and press . to see if the selenium packages are displayed.

Blogs related selenium web driver with C#
1.How to invoke locally different types of browser driver using selenium and c#
2.Creating Basic Selenium web driver test case using Nunit and C#


Related Posts Plugin for WordPress, Blogger...