How to Configure Selenium with Visual Studio in C#

Last updated on Nov 24 2021
Swaminathan M

Table of Contents

How to Configure Selenium with Visual Studio in C#

What is C#?

C# is an object-oriented programing language , which runs on the .Net framework, and it’s pronounced as C-sharp.
C# language is developed to run the CLR, which stands for Common Language Runtime.
In C#, we will break the program into parts with the assistance of functions; that’s why it’s also called a structured programing language .

Why is C# useful for automation testing?

• C# is beneficial for automation testing because it allows the automation test engineer to develop an application with the assistance of Visual Studio on the .Net framework.
• C# is another programing language that also supports the binding with Selenium.
• And this language binding are going to be updated along side the java program.
• C# IDE is Visual Studio, which provides faster development and debugging experience as compared to java’s Eclipse.
• C# features a lot of inbuilt functions, which make the event fast.

Selenium with C#

In this section, we’ll understand the way to download, install the Visual Studio and configure Selenium with Visual Studio, NUnit Framework and execute the test scripts in Visual Studio using C# programming language .

To use selenium with C#, follow the below process:
• Configure Selenium with Visual Studio in C#
• Configure Selenium using NUnit in Visual Studio

Following are the method , to configure Selenium with visual studio in C#:

• Download and install C# IDE (Visual Studio)
• Create a replacement project in Visual Studio
• Add References in Visual Studio
• Write a Selenium test script using C#
• Run Selenium test script in Visual Studio

Download and install Visual Studio

Visual Studio may be a C# IDE [Integrated Development Environment], which is employed to develop applications on various platforms like Windows, Mac, etc.

Here, we are downloading and installing the Visual Studio for Windows platform.

Download Visual Studio

To download the newest version of Visual Studio for Windows platform, ask the below link: https://visualStudio.microsoft.com/downloads/
• Once we clicked on the above link, within the Downloads section, we’ll click on the Free Download button under the Community area as we will see within the below screenshot:

visual 1
Download

• Once we clicked on the Free Download button, it’ll download the exe file of the visual Studio.
• After that, open the downloaded exe file as we will see within the below screenshot:

visual 2
Visual Studio

Install Visual Studio

After downloading the Visual Studio for Windows platform, we’ll be able to install it.

To install the Visual Studio, follow the below process:

• Once we double-click on the downloaded executable file, the Visual Studio Installer window will appear on the screen, where we clicked on the Continue button for further process as we will see within the below screenshot:

visual 3
executable file

• After clicking on the continue button, it’ll start installing the files for the visual Studio.

visual 4
continue

• Once this process is completed , installing -visual Studio-community 2019-16.4.3 window will appear on the screen where we select the Universal Windows Platform development and .Net desktop development options under the Desktop & Mobile section.
• And click on the Install button as we will see within the below screenshot:

visual 5
Install

• The installation process will take a while to put in because the file size is big as we will see within the below screenshot:

visual 6
process

• When the installation process is completed , we’ll click on the Restart button before starting the visual Studio.

visual 7
Restart

• Once the system is rebooted (restart), we’ll search “Visual Studio 2019” on the beginning menu and double-click thereon .
• The following pop-up will appear on the screen, and that we will click on the Not now, maybe later if we don’t have an account as we will see within the below screenshot:

visual 8
pop-up

• In subsequent window, we will select the theme for the Visual Studio.
• After selecting the theme of the Visual Studio, click on the beginning Visual Studio button as we will see within the below image

visual 9
selecting theme

• and that we got the beginning window of Visual Studio.

visual 10
Visual Studio

Create a replacement Project

Once the installation is completed , we are ready to create a replacement project on the Visual Studio.
To create a project on the Visual Studio, follow the below process:

• Right-click on the File menu, attend New and choose Project option within the given pop-up menu as we’ll see within the below screenshot:

visual 11
New Project

• Create a replacement project window will appear on the screen, where we’ll select C# language within the All language drop-drown menu.
• Then, select Windows platform options from All platforms drop-down list.
• and appearance for .net Framework template within the search field, and choose Console App (.NET Framework) from it.
• then , click on subsequent button as we’ll see within the below screenshot:

visual 12
.NET Framework

• Once we clicked on subsequent button, Configure your new project window will appear on the screen, where we’ll provide our Project name [SeleniumTest], and clicking on the Create button as we’ll observe within the below screenshot:

visual 13
Configure new project

• Once the project is successfully created, the next window will appear on the screen:

visual 14
successful

Add References in Visual Studio

Once the project creation is completed , we’ll add the References of Selenium WebDriver and Chrome driver with the help of the NuGet Package Manager within the Visual Studio.

Add Selenium WebDriver References

Follow the below process, to feature references of Selenium WebDriver in Visual Studio:
• within the answer Explorer, right-click on the References and choose Manage NuGet Packages option within the given pop-up menu as we’ll see within the below screenshot:

visual 15
References

• The Manage NuGet Packages window will open, where we’ll search Selenium and choose the WebDriver, and click on on on the Install button as we’ll see within the below image:

visual 16
Manage NuGet Packages window

• Then, click on the OK button within the Preview change window as we’ll see within the below image:

visual 17
OK button

• Once the package got successfully installed, it’ll give the below output message.

visual 18
successfully installed

Add Chrome Driver References

Follow the below process, for adding the references to the Chrome Driver in Visual Studio:
• To perform an action on the chrome browser, we’ll be again right-clicking on the References and choose Manage NuGet Packages option from the pop-up menu.
• Then search chrome driver within the search field, and choose the Chrome.WebDriver and click on on on the Install button as we’ll see within the below image:

visual 19
Install Chrome.WebDriver

• And, click on the Ok button within the Preview Changes window for further process.

visual 20
Ok

• After adding the Selenium WebDriver and Chrome driver References within the Visual Studio, we are ready to write our test script within the C# programming language .

So, this brings us to the end of blog. This Tecklearn ‘How to Configure Selenium with Visual Studio in C #’ blog helps you with commonly asked questions if you are looking out for a job in Selenium and Automation Testing. If you wish to learn Selenium and build a career in Automation Testing domain, then check out our interactive, Selenium Certification Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/selenium-training-certification/

Selenium Certification Training

About the Course

Tecklearn’s Selenium Certification Training enables you to master the complete Selenium suite. The Selenium Training is designed to train developers and manual testers to learn how to automate web applications with a robust framework, and integrate it within the DevOps processes of an organization. This Selenium Certification Training will also help you master important concepts such as TestNG, Selenium IDE, Selenium Grid, Selenium WebDriver, etc. Get hands-on experience on widely used automation frameworks such as Data-Driven Framework, Keyword-Driven Framework, Hybrid Framework, and Behavior Driven Development (BDD) Framework. Throughout this online Instructor-led Selenium Certification Training, you will be working on real-life industry use cases.

Why Should you take Selenium Certification Training?

• The average salary of a Selenium Test Automation Engineer is $94k per year – Indeed.com.
• Automation Testing Market is expected to grow at a Compound Annual Growth Rate (CAGR) of 18.0% in the next three years.
• Global software testing market to reach $50 billion by 2020 – NASSCOM. Selenium tool supports more browsers and languages than any other testing tool.

What you will Learn in this Course?

Getting started with Selenium

• Introduction to Selenium testing
• Significance of automation testing
• Comparison of Manual and Automation Testing
• Installation of Java JDK, JRE and Eclipse

Setting the environment in Eclipse for Selenium

• Java Introduction
• Creating a Java function and executing
• Concepts of Java
• Properties File
• Reading Data from Excel File
• Database Connection
• Hands On

Advantages of Selenium automation testing

• Selenium Features
• Concept of Selenium Integrated Development Environment
• Understanding of the Selenium IDE features
• Addition of Script assertions and general commands
• Deploying the first Selenium Script
• Sample project IDE
• Recording Selenium test case
• Hands On

Selenium Web driver Automation

• Architecture of Selenium Web Driver
• Download and installation
• Creating a Java function using Selenium and execution
• Hands On

Deploying Web Drivers for scripting

• Getting the HTML source of Web Element
• Table and Form Elements
• Firebug extension and Fire Path installation
• Advance User Interactions and Cross Browser Testing
• Hands On

Deep dive into Selenium Web Driver

• Action Commands
• Web Table / Date Picker
• How to Implement Switching Commands in WebDriver
• Alerts
• Frames
• Hands On

Switching Operations in WebDriver using Window

• Selenium Webdriver Wait
• Implicit wait, Explicit wait
• Deploying searching elements using the link text, name, using XPath
• Calendar
• Hands On

Introduction to TestNG Framework

• Introduction to TestNG
• Advantages of TestNG
• Installing TestNG on Eclipse
• Rules to write TestNG
• TestNG Features
• Annotations
• Grouping
• Sequencing: Prioritization and Dependency
• Enable/Disable a test case
• Parameterization: Using Xml file and DataProvider
• Parallel Testing & Cross Browser Testing
• TestNG Report: HTML Report, Console Report, XML Report

JUnit Operations and Test Framework

• Annotations, Methods in JUnit
• Junit Test Suites, ANT Build and JUNIT reporting
• Types of Test Automation Framework
• Module Based Testing Framework
• Data Driven Testing Framework
• Keyword Driven Testing Framework
• Hybrid Driven Testing Framework
• How to implement Testing Framework in Project

Object Repository

• Understanding of Object Repository
• Learning sample scripts using object repository
• Page Object Modelling
• Page Factory

JavaScript Functions

• Autosuggestion
• Headless Browser
• Sikuli
• XPath

Got a question for us? Please mention it in the comments section and we will get back to you.

0 responses on "How to Configure Selenium with Visual Studio in C#"

Leave a Message

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