Skip to main content

Selenium With xUnit


Run xUnit Selenium tests on the TestMu AI cloud grid. This guide covers setup, running a sample test, configuring capabilities, and running tests in parallel.

Sample repo

All the code used in this guide is available in the sample repository.

Prerequisites


Make sure you have the following set up before you start.

  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 .NET Core SDK 8.0 or later.
  4. Download Selenium WebDriver Language Binding for C#.

Step 1: Clone the Sample Project


Pull the sample repo to your local machine and navigate into the project directory.

git clone https://github.com/LambdaTest/CSharp-xUnit-Selenium
cd CSharp-xUnit-Selenium

Step 2: Set Your Credentials


Add your TestMu AI credentials as environment variables so the test can authenticate with the grid.

Visit the TestMu AI Dashboard, navigate to the left sidebar, and select Credentials. Copy your Username and Access Key, then set them as environment variables:

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

Step 3: Configure Your Test Capabilities


Define the browser, version, and OS for your test run.

Update the config.json file with your desired capabilities:

{
"server": "hub.lambdatest.com",
"user": "LT_USERNAME",
"key": "LT_ACCESS_KEY",

"capabilities": {
"lt:options": {
"buildName": "xunit build",
"sessionName": "lambdatest xunit sample test",
"visual": "true",
"plugin": "xunit:sample"
}
},

"environments": [
{
"browserName": "chrome"
},
{
"browserName": "firefox"
},
{
"browserName": "safari"
}
],

"TunnelOptions": {
"tunnel": false
}
}
tip

Use the Capabilities Generator to auto-generate capabilities for any browser, version, and OS combination.

Step 4: Run the Test


Build and run xUnit tests from Visual Studio or the command line.

From Visual Studio: Build the solution and run tests from the Test Explorer.

From the terminal (macOS/Linux):

dotnet clean
dotnet test --filter "profile=single"

To run tests in parallel:

dotnet test --filter "profile=parallel"

Step 5: View Your Results


Check the Automation Dashboard to see exactly what happened during your test.

Visit the TestMu AI Automation Dashboard to see your test results. Each session includes:

  • Video recording of the full test execution
  • Screenshots captured at each step
  • Console logs from the browser
  • Network logs for every request and response
  • Selenium command logs showing each driver action

Run xUnit Tests Using Agent Skills


Use AI coding assistants to generate and run xUnit tests with the TestMu AI Agent Skill.

The xunit-skill is part of TestMu AI Agent Skills - structured packages that teach AI coding assistants how to write production-grade test automation.

Install the skill:

git clone https://github.com/LambdaTest/agent-skills.git
cp -r agent-skills/xunit-skill .claude/skills/

# For Cursor / Copilot
cp -r agent-skills/xunit-skill .cursor/skills/
tip

Install all available framework skills at once by cloning the repository directly into your tool's skills directory (e.g., .claude/skills/, .cursor/skills/).

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles