Setup required
- Visual Studio 2013+
- Internet for downloading the packages from NuGet packages.
Required Knowledge
- Basic C# Scripting knowledge
- Basic HTML (for finding elements)
Introduction
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.
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.
- Open Visual Studio 2013+
- Click File >> Create a New project

- Click on Visual C# for choosing the language

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

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

- Search Selenium On Browse content of NuGet UI.
Install Selenium.webDriver to your solutions,
- Search with Selenium.Chrome.WebDriver on Browser UI,
Install Selenium.Chrome.WebDriver,
- 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. - Go to the driver folder
- 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.

- Go to your project and the open your UnitTest1.cs (Default)
Paste the below code.- [TestClass]
- public class UnitTest1
- {
- [TestMethod]
- public void TestMethod1()
- {
- //Path of chromedriver.exe:
- IWebDriver driver = new ChromeDriver(@"C:\Users\Suman\FirstSeleniumDemo\packages\Selenium.Chrome.Web Driver.2.40\driver"); //<-Add your path
- driver.Navigate().GoToUrl(@"https://www.c-sharpcorner.com/");
- }
- }
Now, run the test case.
You can open a website using Selenium Chrome driver using C# note.
Thanks a lot.
You can open a website using Selenium Chrome driver using C# note.
Thanks a lot.

Vaishali ValaPosted May 6, 2020, 12:46 AM
Hey I need one help in c# automation - I want to know how to automate code for login with field validation means already register or wrong email like that can you help me?
hitesh dograPosted Mar 7, 2020, 10:48 PM
Why i am getting namespace error. I think something you missed
Bhavesh JadavPosted Aug 6, 2018, 6:48 AM
Very good starting Suman.