For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

How to Run Selenium Tests With C# on TestMu AI


Run your C# Selenium tests on the TestMu AI cloud grid across 10,000+ browser/device combinations. The setup is the same for every framework: you connect to the grid and pass your capabilities. This guide covers that shared flow once, then gives you a per-framework quickstart in the tabs below.

Prerequisites​


Complete these before running any framework below.

  1. Create a TestMu AI account if you don't have one.
  2. Get your Username and Access Key from the TestMu AI Dashboard.
  3. Install the .NET Core SDK 2.1 or later (MSTest needs 3.0.0).
  4. Install the Selenium WebDriver C# bindings.

Set Your Credentials​


Every framework authenticates the same way: your Username and Access Key are read from environment variables. Set them once. Pick your operating system:

Verified
export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

How the Sample Test Works​


Every framework below connects to the grid and passes your browser and OS choices through an LT:Options object:

Verified
var browserOptions = new ChromeOptions();
browserOptions.PlatformName = "Windows 10";
browserOptions.BrowserVersion = "latest";

var ltOptions = new Dictionary<string, object>
{
{ "username", LT_USERNAME },
{ "accessKey", LT_ACCESS_KEY },
{ "project", "Demo LT" },
{ "w3c", true }
};
browserOptions.AddAdditionalOption("LT:Options", ltOptions);

What changes between frameworks is only the test runner and how you launch it. That is what each tab covers.

tip

Use the Capabilities Generator to build an LT:Options block for any browser, version, and OS combination.

Run a Test in Your Framework​


Each tab lists the framework-specific pieces. Clone the matching repo (it contains the full, ready-to-run project), then build and run.

NUnit runs from the Visual Studio Test Explorer, or from the CLI on Linux/macOS.

  1. Clone the sample GitHub project:
Verified
git clone https://github.com/LambdaTest/CSharp-NUnit-Selenium
cd CSharp-NUnit-Selenium
  1. Set your browser and OS in the LT:Options object:
Verified
var browserOptions = new ChromeOptions();
browserOptions.PlatformName = "Windows 10";
browserOptions.BrowserVersion = "latest";

var ltOptions = new Dictionary<string, object>
{
{ "build", "NUnit Build" },
{ "name", "NUnit Test" },
{ "w3c", true }
};
browserOptions.AddAdditionalOption("LT:Options", ltOptions);
  1. Build the solution, then run in the Test Explorer, or on Linux/macOS:
Verified
dotnet test

The test then appears on the Automation Dashboard. A green status confirms it passed.

View Your Results​


Your test results appear on the TestMu AI Automation Dashboard.

Your test results, including video, network logs, and command-by-command execution, appear on the TestMu AI Automation Dashboard.

Next steps: If this is your first run, walk through running your first Selenium test end to end. From there, explore the full set of Selenium automation capabilities you can pass to the grid, learn how to debug your Selenium tests, and organize and filter your Selenium tests as your suite grows.

Next Steps​


Continue with these related guides:

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles