Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Set Up Selenium WebDriver for MSTest

Set up Selenium WebDriver in an MSTest project, launch a local browser with ChromeDriver, and understand package versions, project styles, and common setup snags.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run a local Selenium browser test with MSTest, create a .NET test project, add Selenium.WebDriver from NuGet, and launch a browser with a ChromeDriver inside an MSTest test method. For a new project that can use the standard .NET SDK, Microsoft’s MSTest.Sdk is the simplest first-party setup; projects that need another base SDK can use explicit test-package references instead. The local quick-start path uses Selenium Manager for driver setup and does not require Selenium Server.

Choose an MSTest project setup

Use MSTest.Sdk for a new test project when it can be the project’s base SDK. Microsoft describes it as a first-class MSTest setup with runner and Microsoft.Testing.Platform defaults. If the project must use a different top-level SDK—such as Microsoft.NET.Sdk.Web—configure MSTest with package references instead. Confirm that the chosen packages and test runner fit the target framework and repository’s existing test infrastructure.

Option A: MSTest.Sdk for a new test project

Create a project with the .NET CLI, then edit its project file to use MSTest.Sdk as the SDK. The SDK’s version and exact project-file settings should be selected from Microsoft’s current documentation rather than copied from a stale example. Keep the MSTest runner configuration consistent with how the repository discovers and runs tests.

Option B: conventional package references

Use explicit package references when the project needs another base SDK or when the repository already follows the VSTest integration path. Selenium’s published sample uses Microsoft.NET.Test.Sdk, MSTest.TestAdapter, MSTest.TestFramework, Selenium.Support, and Selenium.WebDriver. That sample targets net8.0 and pins Microsoft.NET.Test.Sdk 17.11.1, MSTest packages 3.6.0, and Selenium packages 4.49.0; these are sample values, not a guarantee of the latest versions. See Selenium’s installation instructions and Microsoft’s MSTest introduction for current setup details.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add Selenium WebDriver to the test project

Install the WebDriver package from the directory containing the test project:

dotnet add package Selenium.WebDriver

Alternatively, add a PackageReference to the project file. On the research date, NuGet surfaced Selenium.WebDriver 4.50.0 and listed support for .NET Framework 4.6.2, .NET Standard 2.0, and .NET 8.0. Selenium’s downloads page listed .NET/C# stable 4.49.0, released September 9, 2026, while its installation sample also used 4.49.0. Because those official sources did not agree on the newest version, check the Selenium.WebDriver NuGet page when setting up and avoid copying an older sample pin without verification.

Selenium.Support is optional for the basic Chrome launch below. Add it only if the test needs its helper APIs. If both Selenium packages are used, keep their versions aligned: the NuGet listing for Selenium.Support 4.50.0 declares a dependency on Selenium.WebDriver 4.50.0 or later. See the Selenium.Support NuGet page.

Write and run a minimal MSTest browser test

With the test project and package in place, create a test class that launches Chrome, opens a page, checks its title, and disposes the driver even if an assertion fails:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;

namespace BrowserTests;

[TestClass]
public class HomePageTests
{
    [TestMethod]
    public void HomePageHasExpectedTitle()
    {
        using var driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://example.com");

        Assert.AreEqual("Example Domain", driver.Title);
    }
}

Run the test with dotnet test from the test project’s directory. The Selenium quick-start documentation establishes the ChromeDriver launch pattern; the code above adapts that pattern to MSTest. It is an example, not a claim of a separately performed test run. Replace the example URL and expected title with a page and assertion appropriate to your application.

Understand browser and driver prerequisites

For the documented local quick start, Selenium Manager handles browser-driver installation, so manually downloading ChromeDriver is not normally a first setup step. The browser itself must still be installed and usable in the environment where the test runs. The Selenium installation and downloads pages describe this local workflow and distinguish it from remote execution: installation and downloads.

A local WebDriver script does not need Selenium Server. Selenium Server is for Remote WebDriver and Grid scenarios, such as remote or distributed execution; introduce it when that is the execution model you need, not merely to launch a local browser.

Check the setup when a test will not run

  • The project cannot use MSTest.Sdk: Keep its required base SDK and configure MSTest manually with compatible packages and runner settings.
  • NuGet reports an incompatible framework or package: Check the target framework against the package’s supported frameworks, then select versions that are available and compatible. The Selenium.WebDriver NuGet listing noted above listed .NET Framework 4.6.2, .NET Standard 2.0, and .NET 8.0; confirm current compatibility on NuGet before pinning.
  • Build or restore fails after adding Selenium.Support: Align its version with Selenium.WebDriver. The documented 4.50.0 Support package requires WebDriver 4.50.0 or later.
  • The test runner does not discover the test: Check whether the project uses the MSTest runner/Microsoft.Testing.Platform defaults or the VSTest path, and make its SDK, adapter, framework, and runner settings consistent.
  • Browser startup fails: Confirm the browser is installed and can run in the test environment. Selenium Manager’s driver handling does not install the browser itself.
  • You are trying to add Selenium Server for a local test: Remove that extra setup unless you are switching to Remote WebDriver or Grid.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need screenshots rather than interactive browser assertions, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF; its capture flow accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets, with each step configurable. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify outcomes with X-Page-Verdict and X-Billed headers. Its MCP server provides screenshot and PDF tools for AI agents. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Here is a cURL example; replace the URL with the page you need. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Do I need to install Selenium Server for a local MSTest test?

No. Selenium Server is for Remote WebDriver or Grid execution; a local browser test does not require it.

Is Selenium.Support required to create a ChromeDriver?

No. The basic ChromeDriver example needs Selenium.WebDriver; add Selenium.Support only when you need its helper APIs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.