Skip to main content

Selenium With SpecFlow


Run SpecFlow tests on the TestMu AI cloud grid. This guide covers setup, running a sample test, configuring capabilities, and testing locally hosted pages.

Sample repo

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

Prerequisites


Complete the following steps before running SpecFlow Selenium tests.

  1. Download and install Selenium WebDriver from the official website.
  2. Install the latest version of SpecFlow.
  3. Install the .Net framework for developing applications using C#.
  4. Download Selenium WebDriver Language Binding for C# and extract them to the appropriate folder.
  5. Install a .NET Core SDK of 2.1 or greater version.
  6. Get your TestMu AI Username and Access Key from the TestMu AI Dashboard.

Step 1: Clone the Sample Project


Clone the repository and navigate to the project directory.

git clone https://github.com/LambdaTest/SpecFlow-Selenium-Sample
cd SpecFlow-Selenium-Sample

Step 2: Set Your Credentials


Configure your credentials to connect to the TestMu AI Selenium Grid.

Set TestMu AI Username and Access Key in environment variables.

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

Step 3: Configure Your Test Capabilities


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

In the test script, update your test capabilities. This code passes browser, browser version, and operating system information, along with TestMu AI Selenium grid capabilities via the capabilities object.

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

var ltOptions = new Dictionary<string, object>
{
{ "build", "SpecFlow Build" },
{ "name", "SpecFlow Test" },
{ "w3c", true }
};
browserOptions.AddAdditionalOption("LT:Options", ltOptions);
Capabilities Generator

Use the TestMu AI Capabilities Generator to auto-generate the capabilities class for your test requirements.

Step 4: Run the Test


Execute the SpecFlow test from Visual Studio.

  1. Build the solution by clicking Build > Build Solution.
  2. Open Test Explorer in Visual Studio.

cmd

  1. Click Run from the Test Explorer to run the sample test.

cmd

To run parallel tests, click Run All in Test Explorer.

Step 5: View Your Results


Check the test output on the console and the TestMu AI dashboard.

Visit the TestMu AI Automation Dashboard to view your test results. The dashboard provides:

  • Text logs for each test step
  • Screenshots captured during execution
  • Video recordings of the full test session

Run SpecFlow Tests Using Agent Skills


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

The specflow-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/specflow-skill .claude/skills/

# For Cursor / Copilot
cp -r agent-skills/specflow-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