12 steps of Selenium WebDriver Setup with C#

From the last few years I was trying to familiar with not just the Microsoft Visual Studio C# ties for Selenium IDE, but also Visual Studio as a full. In my todays article I will try to describe how to go about setting up the basics, and in future I will try to write more articles on how to change (or improve, depending on your preference) the solution that you come out with.

What You Need to do

1. Microsoft Visual Studio 2008/12 IDE – where you can write and execute the C# code. In my today’s article I will use Chrome browser and Visual Studio 2008 IDE.

2. Download the Selenium C# files from the selenium website.

Selenium-C#-language

Download the Selenium C# files from the selenium website

3. Download the browser’s drivers. It can be Chrome / Opera / IE / Mozilla Firefox etc.

Selenium-third-Party-Browser-Driver

Download the browser’s drivers. It can be Chrome / Opera / IE / Mozilla Firefox etc.

4. Go to Visual Studio 2008 IDE.

5. Open Visual Studio IDE, Create New Project, Select Console application.

6. Give a name of your project.

7. It will open the coding area.

8. Now click on the “Project” menu.

9. Click on the “Add reference” menu and browse .net 3.5 or .net4.0 from your downloaded C# files. As I am using Visual Studio 2008 that’s why adding net35 reference files.

10. Now add below all related references in the namespace.

using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

Selenium-C#-Reference

11. Now write your first Webdriver code as like below and press Start Debugging(F5). This will automatically open http://techinews24.com site in the chrome browser.

namespace WebdriverTest
{
    class Program
       {
             static void Main(string[] args)
              {
                     IWebDriver d = new ChromeDriver();
                     d.Navigate().GoToUrl(“http://techinews24.com”);
              }
        }
}

Selenium-Main-Code

Full C# Source Code

12. This will end the Selenium Webdriver integration with the Microsoft Visual Studio C#

2 Comments
  1. June 12, 2015
    • June 13, 2015

Leave a Reply

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