Selenium Automation Using C# - Part One

Setup required
  1. Visual Studio 2013+
  2. Internet for downloading the packages from NuGet packages.
Required Knowledge
  1. Basic C# Scripting knowledge 
  2. Basic HTML (for finding elements) 

In this blog, we are going to automate a website using C# Selenium. It is the first step of automation. In this below topic, we are using Selenium, Chrome driver, and C# for scripting.

Steps to follow

Below are some of the images to start the automation.
  1. Open Visual Studio 2013+
  2. Click File >> Create a New project


  3. Click on Visual C# for choosing the language


  4. Click on "Test" for creating a test project.
  5. Select Unit Test Project Template. Create the project with a suitable name


  6. Open your project and click on Tools on topbar of Visual Studio.
  7. Click on NuGet Package Manager.
  8. Click on Manage NuGet Package for the solution.


  9. Search Selenium On Browse content of NuGet UI.

    Install Selenium.webDriver to your solutions,


  10. Search with Selenium.Chrome.WebDriver on Browser UI,

    Install Selenium.Chrome.WebDriver,


  11. Now, all setup is covered for our topics. Now we will go to the coding part.

    Now, go to the path of your Project folder and go to packages.

    1. Go to the driver folder
    2. Copy the Path of the driver under where chromedriver.exe is available. This will be available after the installation of the above packages into our solution.


  12. Go to your project and the open your UnitTest1.cs (Default)

    Paste the below code.
    1. [TestClass]  
    2. public class UnitTest1  
    3.    {  
    4.    [TestMethod]  
    5.    public void TestMethod1()  
    6.    {  
    7.       //Path of chromedriver.exe:  
    8.       IWebDriver driver = new ChromeDriver(@"C:\Users\Suman\FirstSeleniumDemo\packages\Selenium.Chrome.Web      Driver.2.40\driver"); //<-Add your path  
    9.       driver.Navigate().GoToUrl(@"");  
    10.    }  
    11. }  
Now, run the test case.

You can open a website using Selenium Chrome driver using C# note.

Thanks a lot.