Configuring Microsoft Visual Studio for Selenium WebDriver test development
Selenium WebDriver provides .NET bindings to develop Selenium tests with the .NET platform. To use the Selenium WebDriver API along with .NET, you need to refer the Selenium WebDriver libraries to the project. Microsoft Visual Studio being the major IDE used in the .NET world, setting up the Selenium WebDriver support has become easier with NuGet Package Manager (http://nuget.org/).
This recipe explains the process of setting up Selenium WebDriver in Microsoft Visual Studio 2013 using NuGet.
Getting ready
NuGet comes bundled with Microsoft Visual Studio 2012 onwards. However, for Microsoft Visual Studio 2010, you will need to download and install NuGet from http://nuget.codeplex.com.
How to do it...
Let's configure Microsoft Visual Studio 2013 to develop Selenium WebDriver tests using the following steps:
- Launch the Microsoft Visual Studio.
- Create a new project by selecting File | New | Project from the main menu.
- In the New Project dialog box, select Visual C# | Test | Unit Test Project. Name the project as SeleniumCookbook and click on the OK button, as shown in the following screenshot:
- Next, add Selenium WebDriver packages using NuGet. Right-click on the SeleniumCookbook solution in Solution Explorer and select Manage NuGet Packages…, as shown in the following screenshot:
- On the SeleniumCookbook - Manage NuGet Packages dialog box, select Online and search for the
WebDriver
package. The search will result in the suggestions shown in the following screenshot: - Select Selenium WebDriver from the list and click on the Install button. Repeat this step for Selenium WebDriver Support Classes. Successful installation will show a green tick mark for both the packages, as shown in the following screenshot:
- Close the SeleniumCookbook - Manage NuGet Packages dialog box.
- Expand the References tree for the SeleniumCookbook solution in Solution Explorer. References for WebDriver are added to the project as shown in the following screenshot:
- The
SeleniumCookbook
project is ready for test development. You can go on adding new tests as needed.
How it works...
NuGet Package Manager adds the external dependencies to Microsoft Visual Studio projects. It lists all available packages and automatically downloads and configures packages to the project. It also installs dependencies for the selected packages automatically. This saves a lot of effort in configuring the projects initially.