To set up Selenium in Microsoft Visual Studio, add the Selenium.WebDriver NuGet package to a C#/.NET project, then create a ChromeDriver instance and run a small browser interaction. Selenium Manager handles browser-driver management by default, so downloading a driver separately is not a required first step.
What you need
- Microsoft Visual Studio and a C#/.NET project.
- A working .NET SDK for the project.
- A browser you can run on the machine. The example below uses Chrome.
Selenium’s .NET examples use SDK-style projects. The Selenium .NET/C# downloads page listed version 4.49.0 as stable, released September 9, 2026; versions change, so check the current Selenium downloads page rather than treating that version as permanent guidance.
As an Amazon Associate I earn from qualifying purchases.
Install Selenium.WebDriver
Option 1: Visual Studio NuGet Package Manager
- In Visual Studio, open the solution and select the C# project that will run the automation.
- Open NuGet Package Manager for that project, search for
Selenium.WebDriver, and install the package. - Confirm the package appears as a dependency of the intended project before building.
Visual Studio labels can vary by version; the important point is to add the package to the project, not merely to the solution.
Option 2: .NET CLI
Open a terminal in the directory containing the project file and run:
#1 Best Overall
dotnet add package Selenium.WebDriver
This adds a package reference to that project. Selenium also documents the equivalent project-file entry:
<PackageReference Include="Selenium.WebDriver" Version="4.49.0" />
Use the current package version shown by NuGet or Selenium’s download page when creating a new project; the version above reflects the Selenium downloads listing on September 9, 2026.
Rank #2
Run a first browser session
Create a C# file in the project and use this minimal interaction, based on Selenium’s official sample web form:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
var driver = new ChromeDriver();
try
{
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
var title = driver.Title;
Console.WriteLine($"Page title: {title}");
var textBox = driver.FindElement(By.Name("my-text"));
textBox.SendKeys("Selenium in Visual Studio");
driver.FindElement(By.TagName("button")).Click();
var message = driver.FindElement(By.Id("message")).Text;
Console.WriteLine($"Result: {message}");
}
finally
{
driver.Quit();
}
The example opens Selenium’s demonstration form, enters text, clicks its button, and prints the returned message. Run the project from Visual Studio as you would any other console application. If you prefer, use the terminal in the project directory with dotnet run.
The try/finally ensures the browser session is asked to close even if an operation throws an exception. For a short-lived program, call Quit() once when the session is finished; avoid leaving browser processes running between repeated runs.
How browser and driver setup works
Selenium says its bindings use Selenium Manager by default for automated browser and driver management. The project overview describes it as “a command-line tool implemented in Rust that provides automated driver and browser management for Selenium.” In a normal first run, start with new ChromeDriver() rather than assuming you must manually download and configure a driver executable.
Rank #4
Manual setup may still be needed in constrained environments or when your team deliberately manages browser and driver versions itself. Selenium’s overview establishes the default manager behavior, but exact remediation depends on the machine, browser, network policy, and error message.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Choose between a script and a test project
One-off automation or a smoke test
A console application is sufficient to prove that Selenium can start a browser, navigate, and interact with a page. It does not require a test framework just to run a few steps.
Best Value
A growing automated test suite
As checks multiply, put them in a test project and use a .NET test runner/framework to organize test cases, assertions, and setup and teardown. Selenium’s organizing guide describes runners as useful for advanced test organization and includes .NET examples, while noting that portions of the guide are incomplete. It does not make a particular framework mandatory for every Selenium user.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting the first run
- Visual Studio cannot resolve
OpenQA.Selenium. Check thatSelenium.WebDriverwas installed in the project containing the source file, then restore NuGet packages and rebuild. - The package command reports no project. Run
dotnet add package Selenium.WebDriverfrom the directory containing the intended.csproj, or specify the project path. - Chrome does not start. Confirm Chrome is installed and can launch for the current user. Read the full exception; check machine permissions and whether network restrictions prevent Selenium Manager from doing its work.
- The browser opens and immediately closes. Ensure the program has not exited and reached its
finallyblock; when debugging, set a breakpoint beforeQuit()or inspect the exception that occurred first. - An element lookup fails. Confirm the target page loaded and that the locator matches the current page. A missing element can reflect a changed page, timing, or an incorrect selector rather than an installation problem.
- The test passes locally but not in another environment. Compare installed browser availability, user permissions, network policy, and the exact Selenium exception before resorting to a manually pinned driver.
Or skip the browser setup
If the job is simply to capture a webpage rather than interact with it, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. Its clean-shot workflow accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers reporting the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf.
cURL example (see the ScreenshotNeo API documentation):
Recommended Free Tools
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo also has Python and Node.js examples in its documentation. Its free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




