WebDriver is a tool for automating testing web applications, and, in particular, to verify that they work as expected. It aims to provide a friendly API that’s easy to explore and understand, which will help make your tests easier to read and maintain. It’s not tied to any particular test framework so that it can be used equally well with MSTest, NUnit, TestNG, JUnit and so on. This “Getting Started” guide introduces you to WebDriver’s C# API and helps get you started becoming familiar with it.

Create Your First WebDriver Test Project

1. Create New Test Project in Visual Studio.

2. Install NuGet package manager and navigate to it.

3. Search for Selenium and install the first item in the result list

Code Examples In WebDriver

Create an instance of a driver.

Only the FirefoxDriver can be created without parameters. For all other drivers you need to point the location where the specific driver is downloaded.



Аdditional steps are required to use Chrome Driver, Opera Driver, Android Driver and iPhone Driver

Locating Elements with WebDriver

By ID

By Class (Find more than one element on the page)

By Tag Name

By Name

By Link Text

By XPath

By CSS Selector

Chaining Locators

to specific

Use a Chain of Locators in order to find a specific element.

IWebElement Methods

IWebElement Properties

HTML Element Actions in WebDriver

Type Text into a field using Selenium WebDriver SendKeys() function.

Select Drop Down Value. First you need to add NuGet Package to your project- Selenium.Support.

You can find a lot more code and examples in the official WebDriver C# Documentation.