Motus is a browser automation and testing framework for .NET that talks straight to Chromium and Firefox over CDP and WebDriver BiDi. No Node.js sidecar, no driver binary, no process boundary. Source-generated bindings, NativeAOT-ready, and every built-in feature is a plugin.
Every .NET browser automation framework either wraps a JavaScript tool behind a process boundary or bolts extensibility on as an afterthought. Motus does neither.
It speaks to the browser over a raw WebSocket: the Chrome DevTools Protocol for Chromium, WebDriver BiDi for Firefox. Protocol types are source-generated at build time and marshalled with System.Text.Json source generators, so the engine is reflection-free and NativeAOT-ready. And every built-in selector strategy, lifecycle hook, wait condition, and reporter is registered through the same public plugin context any consumer can use. If a built-in needed private access, the interfaces would be incomplete.
No Node.js process to proxy commands, no chromedriver or geckodriver to version and manage. Motus holds the WebSocket itself and dispatches trusted, browser-level events with nothing in between your test code and the protocol.
See the architecture
The five built-in selector strategies, the console, HTML, JUnit, and TRX reporters,
the visual runner timeline, and the nine WCAG rules are all registered through the
same IPluginContext your own plugins use. No internal shortcuts.
Locators that never go stale, auto-retrying assertions, network mocking, accessibility and performance budgets, coverage, and full tracing. Nothing to bolt on, no third-party packages for the essentials.
CSS, XPath, Text, ARIA Role, and Test ID strategies, plus semantic helpers like GetByRole and GetByLabel. Add your own with ISelectorStrategy.
Every action waits for the element to be attached, visible, stable, and enabled before acting, with a configurable timeout. Explicit sleeps are unnecessary.
Polling assertions for locators, pages, and responses retry until they pass or time out, with .Not negation. Transient DOM and protocol errors are retried, not thrown.
Intercept any request by URL glob. Mock with FulfillAsync, forward with ContinueAsync, or cancel with AbortAsync, on a page or a whole context.
WCAG 2.1 Level A/AA audits against the browser's native accessibility tree, no JavaScript injection. Nine rules built in, extensible via IAccessibilityRule.
Core Web Vitals (LCP, FCP, TTFB, CLS, INP) collected during the run. Set budgets with [PerformanceBudget] or config and regressions fail the test.
Per-test JavaScript and CSS coverage via CDP, remapped to original sources, aggregated across the run, with thresholds that fail the build in CI.
Screenshots, DOM snapshots, network logs, HAR export, and WebM video. Trace archives open in the visual runner with a full timeline.
Context-level, browser-level, and worker-level parallel execution, with a browser pool that detects crashes and replenishes itself.
Open shadow roots are pierced automatically, configurable per locator, so components built on web components stay addressable.
Drive a browser you did not start. Connect to a debugging endpoint and its open tabs are yours, including signed-in profiles, warm browsers reused across runs, and Chromium-based desktop apps. Motus never ends a browser it did not start.
Locators scope to the frame they came from, to any nesting depth. Frames the browser renders in their own process are ordinary frames here, with an isolated world available when the page's scripts are in the way.
Source-generated protocol bindings and plugin discovery mean zero reflection, so Motus trims and publishes ahead-of-time cleanly.
Seven Roslyn diagnostics catch unawaited calls, hardcoded delays, fragile selectors, and undisposed browsers at compile time, with code fixes.
Semantic locators target what users see. Assertions poll until the page settles. Network mocks and accessibility audits are first-class, not add-ons.
page.GetByRole("listitem")
.Filter(new LocatorOptions
{ HasText = "Product A" })
.Locator("button")
.ClickAsync();
await That(page)
.ToHaveTitleAsync("Dashboard");
await That(page.Locator(".spinner"))
.Not.ToBeVisibleAsync();
await page.RouteAsync(
"**/api/products",
async route => await route.FulfillAsync(
new RouteFulfillOptions {
Status = 200,
Body = productsJson }));
await That(page)
.ToPassAccessibilityAuditAsync();
await That(page.Locator("nav"))
.ToHaveRoleAsync("navigation");
Test code talks to locators and assertions. Those talk to pages and contexts. Those talk to a transport that holds a raw WebSocket. Each layer depends only on the public contract below it.
Test framework integrations, the CLI runner, the Blazor visual runner, and an MCP server for AI agents. All consume the same engine.
Browser management, the page controller, locators, selectors, and assertions, plus recording, codegen, and the Roslyn tooling that supports them.
Public interfaces and types with zero dependencies. The only package a plugin author references, and the boundary every layer is written against.
All CDP and BiDi types are source-generated at build time from the protocol schema, and serialization runs through System.Text.Json source generators. The transport holds a raw WebSocket directly: no HTTP round-trip per command, no intermediate process, no Node.js runtime.
The transport layer, end to endEvery extension point in Motus is an interface in Motus.Abstractions, registered through IPluginContext. The same interfaces the built-ins use are the ones you use.
Mark a class with [MotusPlugin] and the Roslyn source generator emits a
module initializer that registers it at startup. No assembly scanning, no reflection.
Or pass instances through LaunchOptions.Plugins for full control.
dotnet add package Motus.Abstractions
The CSS, XPath, Text, Role, and Test ID strategies are plugins. The console, HTML,
JUnit, and TRX reporters implement IReporter. The visual runner's timeline
is an ILifecycleHook. The nine WCAG rules and the audit hook are plugins
too. None has special access to engine internals.
A plugin project references just Motus.Abstractions, which carries the
source generator as an analyzer, so [MotusPlugin] discovery works the
moment you add it.
The same engine that runs your tests is exposed to AI agents through a
Model Context Protocol
server, shipped as the motus mcp verb on the CLI. Agents address elements
by stable references from accessibility-tree snapshots, not brittle coordinates.
They navigate, snapshot, click and type, act at raw coordinates on canvas surfaces including drag and drop, intercept network traffic, run accessibility and performance audits, record traces, HARs, and videos, and generate Page Object Model code, all over stdio or Streamable HTTP.
dotnet tool install --global Motus.Cliclaude mcp add motus -- motus mcpMotus integrates with the three major .NET test frameworks. Pick the package that matches your suite and inherit a base class or wire up a fixture.
One browser shared across the assembly, an isolated context and page per test. Compatible with MSTest parallelization.
dotnet add package Motus.Testing.MSTestA browser per fixture class with no assembly setup, an isolated context and page per test. Works with parallelizable scopes.
dotnet add package Motus.Testing.NUnitA SharedBrowserFixture per collection and a BrowserContextFixture per class, with a ready-made MotusCollection.
dotnet add package Motus.Testing.xUnitmotus record opens a headed browser, captures your interactions, and emits idiomatic C# for MSTest, xUnit, or NUnit, with a configurable selector priority.
motus codegen crawls a live page, infers the best selector for each interactive element, and writes a typed Page Object Model class.
motus run --visual launches a Blazor runner with a live screencast, an action timeline, and step-through controls.
Pixel-level diffs, side-by-side comparison, and baseline management, built into the visual runner.
motus screenshot and motus pdf capture full pages from a URL, with delay, banner-hiding, and sizing options.
motus trace show opens a trace archive in the visual runner with its timeline, screenshots, and network log.
The locator and assertion vocabulary will feel known. The differences are mostly things you no longer have to do.
No bundled Node.js process and no playwright install build step. Swap the launch call, change Expect( to Expect.That(, and inherit MotusTestBase. Method names line up, and accessibility assertions are built in.
Migration guideNo chromedriver or geckodriver to pin. Lazy ILocator objects never go stale, auto-wait replaces explicit waits, and the API is fully async. The PageFactory pattern is no longer needed.
Migration guideA motus.config.json file, then MOTUS_ environment variables, then code, in that order, with code always winning. One place for launch, assertion, accessibility, performance, and coverage settings.
Configuration guideThe one package every project needs: transport, browser management, locators, selectors, and assertions.
dotnet add package Motusdotnet add package Motus.Testing.MSTestThe global tool runs tests, records, generates code, and hosts the MCP server. motus install downloads a browser.
dotnet tool install --global Motus.Climotus installOptional Roslyn analyzers flag the common automation mistakes before a test ever runs, with fixes for several.
dotnet add package Motus.AnalyzersInherit the base class, open a page, act through locators, and assert. The browser is launched once for the assembly and a fresh context is handed to each test.
using Motus.Testing.MSTest; using static Motus.Assertions.Expect; [TestClass] public class SearchTests : MotusTestBase { [TestMethod] public async Task ClickLink() { await Page.GotoAsync("https://example.com"); await Page.GetByRole("link", "More information...").ClickAsync(); await That(Page).ToHaveUrlAsync("*iana.org*"); } }
Motus is a Datafication project, MIT licensed end to end. Issues, discussions, and plugin ideas are welcome.