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.

To run a Selenium browser smoke test with MSTest, create a .NET test project, choose one MSTest test-platform setup, add Selenium WebDriver, and run the test with dotnet test. This guide uses Microsoft’s recommended MSTest.Sdk project style and Selenium’s official web-form example. The code illustrates the documented flow; browser and driver availability can vary by machine.

Choose your MSTest project and test platform

MSTest is the test framework; Selenium WebDriver drives the browser. They are separate components, and a project also relies on a test platform to discover and execute tests. For a new project, Microsoft recommends MSTest.Sdk, an MSBuild project SDK that uses the MSTest runner with Microsoft.Testing.Platform (MTP) by default. See Microsoft’s MSTest getting-started guide.

Recommended here: MSTest.Sdk with MTP

This tutorial uses the SDK-style project path so the example does not mix runner configurations. Microsoft’s guide illustrates MSTest.Sdk/4.1.0 with net10.0; those are documented example values, not a claim that they are the latest available versions. Use a target framework supported by the SDK and your environment, and consult the current guide when choosing versions.

Alternative: MSTest packages with VSTest

Microsoft also documents package-based MSTest setup. It uses packages for the test framework, adapter, analyzers, and VSTest integration. Selenium’s example project follows this style, with MSTest.TestAdapter, MSTest.TestFramework, and Microsoft.NET.Test.Sdk. Do not add those packages to the SDK-style project below unless you are deliberately following the package-based setup and its runner guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Keep the repository consistent

MTP and VSTest are test execution platforms, not alternative names for MSTest. Microsoft advises choosing a consistent platform for a repository’s .NET test projects and tooling. Before adopting MTP, check that the IDE, CI system, and other test projects in your repository work with the platform you select. Details are in Microsoft’s test-platform comparison.

Create the project and install Selenium

  1. Install a .NET SDK supported by your chosen project and test tooling. Selenium’s .NET examples README lists SDK 8.0 or later for running its test suite; this is distinct from its separate file-based script instructions, which require .NET 10 or later. The file-based requirement is not the test-project minimum. See Selenium’s .NET usage instructions.

  2. Create a test project following Microsoft’s MSTest.Sdk getting-started instructions, then add a C# test file such as WebFormTests.cs. The SDK project configuration is the runner choice for this guide.

  3. From the project directory, add Selenium WebDriver:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    dotnet add package Selenium.WebDriver

    This is Selenium’s documented .NET installation command. Its official example project also includes Selenium.Support; add that package only if your tests need the support APIs it provides.

    Rank #2
    Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
    • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
    • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
    • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
    • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
    • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  4. Restore dependencies:

    dotnet restore

The Selenium example project has displayed Selenium packages at 4.49.0, MSTest adapter and framework at 3.6.0, and Microsoft.NET.Test.Sdk at 17.11.1. These are example-project values, not a promise of the latest versions or of cross-version compatibility. The SDK-style project here should follow the versions and configuration recommended for MSTest.Sdk rather than copying the example project’s package-based test runner dependencies.

Write a browser smoke test

The test below follows Selenium’s official C# web-form example: open the form, verify its title, submit text, and assert the response. A try/finally ensures the browser is asked to quit even when an assertion or interaction throws an exception.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace SeleniumMSTest;

[TestClass]
public class WebFormTests
{
    [TestMethod]
    public void SubmittingTextDisplaysConfirmation()
    {
        IWebDriver driver = new ChromeDriver();

        try
        {
            driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");

            Assert.AreEqual("Web form", driver.Title);

            driver.FindElement(By.Name("my-text")).SendKeys("Selenium");
            driver.FindElement(By.TagName("button")).Click();

            string message = driver.FindElement(By.Id("message")).Text;
            Assert.AreEqual("Received!", message);
        }
        finally
        {
            driver.Quit();
        }
    }
}

The example uses MSTest’s [TestClass] and [TestMethod] attributes. Selenium’s documented sample constructs ChromeDriver, navigates to the same URL, checks the title, enters Selenium into the field named my-text, clicks the button, checks the element with ID message for Received!, and quits the driver.

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

This compact smoke test assumes the submitted form responds promptly. For a production suite with variable page load times, prefer explicit waits for the expected state rather than relying on arbitrary sleeps. Keep each test focused on observable behavior, and use lifecycle cleanup if you move driver creation into shared setup.

Run the test and narrow execution

From the directory containing the project file, run:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
dotnet test

The command restores/builds as needed and asks the configured test platform to discover and execute the MSTest test. Selenium’s .NET instructions also show dotnet restore followed by dotnet test. To run one test, use the fully qualified name filter supported by the test tooling, for example:

dotnet test --filter "FullyQualifiedName~SeleniumMSTest.WebFormTests.SubmittingTextDisplaysConfirmation"

If you use a namespace or class name different from this example, adjust the filter to match the test’s fully qualified name.

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

Browser, reliability, and cost considerations

Browser and driver availability

The sample creates ChromeDriver, but the available material does not establish what browsers or driver components are installed on an individual machine, nor guarantee that every local browser setup is compatible. If construction fails, confirm Chrome is installed and that Selenium can obtain or use a compatible driver in your environment. Browser setup can differ between developer machines and CI agents.

Test stability

  • Always close the driver, including after failed assertions; the example uses finally for this.

  • Wait for the condition the test actually needs when page behavior is asynchronous. Avoid fixed delays as a default because they may be too short on a slow run and unnecessarily long on a fast one.

    Rank #4
    Sale
    UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
    • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
    • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
    • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
    • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
    • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • Keep the test-platform choice aligned with the repository’s IDE and CI configuration to avoid discovery or execution mismatches.

    Free tools Windows power users keep installed

    One-click scans. No signup required.

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

Package and execution costs

The documented setup uses the .NET SDK and NuGet packages; no paid Selenium test service is required by this local example. Actual runtime and infrastructure costs depend on the machine or CI environment where the browser runs. The cited setup material provides no benchmark or reliability statistic, so none is implied here.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common setup problems

  • No test is discovered: Check that the test class and method have [TestClass] and [TestMethod], respectively, and that the project uses a consistent MSTest SDK/runner configuration. Do not silently combine MSTest.Sdk defaults with the package-based VSTest setup.

  • dotnet test cannot restore or build: Confirm the required .NET SDK is installed, the project’s target framework is supported, and NuGet restore completes. The Selenium test-suite documentation lists SDK 8.0 or later; separate file-based script prerequisites do not define this project’s minimum.

  • ChromeDriver fails to start: Verify that Chrome is installed and that the browser/driver arrangement is compatible with the Selenium setup on that machine. Browser and driver provisioning is environment-specific; the sample alone does not configure every workstation or CI image.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Best Value
    Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
    • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
    • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
    • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
    • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
    • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  • The title or message assertion fails: Confirm the test reached https://www.selenium.dev/selenium/web/web-form.html, the page loaded successfully, and the expected form controls remain available. If the failure is timing-related, wait for the relevant element or state rather than adding an arbitrary long sleep.

  • The browser remains open after a failure: Ensure driver.Quit() is in a finally block or equivalent test cleanup that runs when the test fails.

  • IDE or CI behavior differs from the command line: Check whether those tools support the selected MTP or VSTest platform and whether the repository uses the same platform consistently.

Or skip the browser setup

If your goal is to capture a webpage rather than test interactive behavior in a browser, ScreenshotNeo offers a screenshot API and MCP server. One GET request can return a screenshot or PDF; its screenshot options include PNG, JPEG, and WebP output. This is not a replacement for Selenium assertions or browser interaction in a test suite.

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

For example, the cURL call below captures a page as WebP:

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

See the ScreenshotNeo API documentation for setup and options. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status in headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can MSTest and Selenium run in the same C# test project?

Yes. MSTest attributes define the tests, while Selenium WebDriver performs browser actions; configure a compatible test platform for discovery and execution.

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

Does this Selenium test require .NET 10?

The Selenium .NET test-suite instructions list .NET SDK 8.0 or later. The .NET 10 requirement applies to separate file-based script instructions, not the test-project minimum.

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.