We know that testing is an essential part of any development process. Prior to every release of a software project/product, it is mandatory to test it end to end and make sure that everything is working as expected. So, Smoke and Regression tests are standards for every new version of a software project/product. Imagine how many resources' efforts are required each time we release a new software project/product. We can reduce resource count and time by automating the process instead of doing it manually, at the times when we plan for a new release of a project/product.
In this article, I am going to show you:

What is Selenium?

Selenium is an automation tool used for writing test cases to automate the web application's functionality. It is an open-source tool to write automation test cases and to test the functionality, automatically. And, it supports across multiple browsers and operating systems.
Selenium
Following are the programming languages supported by the Web Driver:
Now, let's understand the list of tools used in Selenium test cases and their usages.
Selenium IDE: Selenium IDE is a tool that facilitates testers to write and test their Selenium test cases.
Selenium RC: It is a tool that facilitates you to write Selenium automated test cases for web applications irrespective of any programming language and any HTTP websites for the JavaScript-enabled browsers.
Selenium WebDriver: It makes direct calls to the web browser and retrieves results.
Selenium Grid: It allows you to run your test cases across different browsers in different machines, simultaneously.
Advantages of Selenium Test:
Disadvantages of Selenium Test:
How to Install Selenium Webdriver:
Before going to write automation of Selenium test cases, first we have to set up the infrastructure.
In the Visual Studio tool, create a sample test project and integrate Selenium WebDriver in C#.
Step 1: Open Visual Studio.
Step 2: Click on Create a new project, select a Test project from the right panel, and then select the Unit Test Project.
Unit Test project
Step 3: Add Selenium references or drivers into the newly created Unit Test C# project.
references
  1. First, open Solution Explorer.
  2. Then, expand the Project.
  3. Right-click on References and select the Manage NuGet Packages option.
  4. Search for Selenium WebDriver.
  5. Select Selenium WebDriver.
  6. Click on Install.
For reference, find the below screenshots:
Screenshot-1,
reference
After successfully installing the WebDriver, you can see the below screenshot:
Screenshot-2:
reference
And in the references section, you can see the highlighted below:
references
Now, open the UnitTest1.cs (if you want you can rename the file name) file to start actual coding for automating the test cases for your C# Web application.
coding
The above references can provide all classes and properties required to integrate the Selenium WebDriver.
How to Install Chrome Driver in your Web App?
Follow the below steps to add ChromeDriver into the web application C# project.
  1. Firstly, open the 'Solution Explorer'.
  2. Then, expand the 'Project'.
  3. Right-click on References and select the 'Manage NuGet Packages' option.
  4. Search 'ChromeDriver'.
  5. Select 'ChromeDriver'.
  6. Click on 'Install'.
Screenshot-1,
Manage NuGet Packages
Screenshot-2,
Manage NuGet Packages
After successfully installed ChromeDriver, for reference you can see the below screenshot:
ChromeDriver
Now, to write the Selenium test cases, we need a web page. Let's take the below sample code for your webpage to write Selenium test cases:
Example: Login.html
code
Before start writing test methods, we have to understand the below elements and their usages:
Now, it's time to write Selenium Test cases for the above login page:
code
Now, to run the written Test method, right-click on the Test method and click on Run Tests or Debug Tests options, as shown below:
run
If the test method runs successfully without any error, then you will get Passed Tests in your left panel of Visual Studio (Test Explorer), as shown below:
Test Explorer
If the Test method fails with errors, then you will get Failed Tests in your left panel of Visual Studio (Test Explorer), as shown below:
Test Explorer