Installation of Selenium libraries for C# can be done using NuGet in one of two ways
dotnet add package Selenium.WebDriver
Supported .NET Versions
Make sure to use the .NET SDK version compatible with relevant Selenium package.
Check the dependencies section to find out the supported .NET version.
At the time of this update, .NET 5.0 (Visual Studio 2019) is known to be supported, and .NET 6.0 is not supported.
You can download MSBuild Tools 2019 from here to install the needed components and dependencies such as .NET SDK and NuGet Package Manager.
Using Visual Studio Code (vscode) and C#
This is a quick guide to help you get started with vscode and C#, however, more research may be required.
Install the compatible .NET SDK as per the section above.
Also install the vscode extensions (Ctrl-Shift-X) for C# and NuGet.
Follow the instruction here
to create and run the “Hello World” console project using C#.
You may also create a NUnit starter project using the command line
dotnet new NUnit.
Make sure the file
%appdata%\NuGet\nuget.config is configured properly as some developers reported that it will be empty due to some issues.
nuget.config is empty, or not configured properly, then .NET builds will fail for Selenium Projects.
Add the following section to the file
nuget.config if it is empty:
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
For more info about
nuget.config click here.
You may have to customize
nuget.config to meet you needs.
Now, go back to vscode, press Ctrl-Shift-P, and type “NuGet Add Package”, and enter the required Selenium packages such as
Press Enter and select the version.
Now you can use the examples in the documentation related to C# with vscode.