Docs · API reference

API reference

The public .NET API of every Motus package you can reference from your own code, generated from the XML documentation comments in the Motus repository. Most of the surface lives in Motus.Abstractions, which is where the browser, page, frame and locator interfaces are declared; Motus itself is the entry point that hands you one.

For guided introductions, start with Getting started, the testing framework guide, or the plugin authoring guides. The command line, the Roslyn analyzers and the MCP tool catalog are documented in the docs rather than here, since none of them are called from C#.

Motus

The engine entry point: launching browsers, attaching to running ones, the auto-retrying assertion library, and the browser pool. Reference this package to drive a browser from your own .NET code. 10 public types. View on NuGet.

Motus

TypeDescription
MotusBrowserPoolClassFactory for creating browser pools.
MotusLauncherClassPublic entry point for launching and connecting to browsers.
PerformanceBudgetContextClassAmbient performance budget for the current async test flow. Test framework adapters push the resolved budget (from PerformanceBudgetAttribute) at test setup and clear it at teardown. The assertion reads it via Motus.PerformanceBudgetContext.Current. Uses System.Threading.AsyncLocal<> so parallel tests remain isolated.
ReporterCollectionClassThe reporters registered on a browser context, and the fan-out that delivers each lifecycle event to all of them.
TestMethodNameContextClassCarries the current test method name across async boundaries. The visual runner sets this before invoking test lifecycle methods so that MotusTestBase can resolve per-method attributes (e.g. [PerformanceBudget]) without requiring a framework-specific TestContext.

Motus.Assertions

TypeDescription
AccessibilityAssertionOptionsClassConfiguration for the ToPassAccessibilityAuditAsync assertion.
ExpectClassThe entry point to the assertion library: wraps a locator, page, or response in the assertions that apply to it.
LocatorAssertionsClassAssertions about a single locator, obtained from That(ILocator).
PageAssertionsClassAssertions about a page as a whole, obtained from That(IPage).
ResponseAssertionsClassAssertions about a response the browser received, obtained from That(IResponse).

Motus.Abstractions

The contract surface: the browser, context, page, frame and locator interfaces, the options and result types they exchange, and the interfaces a plugin implements. Plugins reference only this package. 123 public types. View on NuGet.

TypeDescription
AccessibilityAuditContextClassProvides rules with access to the full tree and the page during an audit.
AccessibilityAuditResultClassThe outcome of an accessibility audit over a page's accessibility tree.
AccessibilityModeEnumControls how the accessibility audit hook handles violations.
AccessibilityNodeClassRepresents a single node in the browser's accessibility tree.
AccessibilityOptionsClassConfiguration for the built-in accessibility audit hook.
AccessibilitySnapshotClassThe result of fetching a page's accessibility tree. Carries the root nodes (each with its children, forming the full tree), the number of nodes the browser excluded as not accessibility-relevant, and an optional diagnostic message when a snapshot could not be produced (for example on a transport that does not expose an accessibility tree).
AccessibilityViolationClassDescribes a single accessibility rule violation found during an audit.
AccessibilityViolationSeverityEnumClassifies the severity of an accessibility rule violation.
ActionResultClassRepresents the outcome of a browser action performed by the automation engine.
ActionTimeoutExceptionClassThrown when an actionability check (visible, enabled, stable, etc.) times out before the element reaches the required state.
AmbiguousSelectorExceptionClassThrown when a selector matches more elements than expected for strict mode.
AssertionOptionsClassOptions for assertions on pages, locators, and other objects.
BoundingBoxClassRepresents the bounding box of an element in CSS pixels.
BrowserChannelEnumSpecifies the browser distribution channel to use when launching.
BrowserFailureClassTells failures caused by the browser going away from failures the test found.
BrowserPoolOptionsClassConfiguration for a browser pool.
ClipRectClassSpecifies the clipping region for a screenshot.
ColorSchemeEnumSpecifies the preferred color scheme for the browser context.
ComputedStyleInfoClassPre-fetched computed style properties for an element, used by accessibility rules that need CSS information (e.g., color contrast checks).
ConnectOptionsClassOptions for connecting to a browser that is already running.
ConsoleMessageEventArgsClassEvent arguments for console messages emitted by the page.
ContextOptionsClassOptions for creating a new browser context.
CookieClassRepresents a browser cookie.
CoverageDataClassA snapshot of JavaScript and CSS code coverage data collected during a page session.
CoverageOptionsClassConfiguration for the built-in code coverage collector hook.
CoverageRangeClassA contiguous byte-offset range within a script source with an associated execution count.
CoverageSummaryClassAggregated summary across all scripts and stylesheets in a coverage snapshot.
CssRuleUsageClassCSS rule usage entry within a stylesheet source.
DialogEventArgsClassEvent arguments for JavaScript dialog events.
DialogTypeEnumSpecifies the type of JavaScript dialog.
ElementNotFoundExceptionClassThrown when no element matches the given selector.
ElementStateEnumSpecifies the expected state of an element when waiting.
EvaluateOptionsClassOptions for evaluating JavaScript.
ExecutionWorldEnumSpecifies which JavaScript world an expression is evaluated in.
FileCoverageStatsClassPer-file coverage statistics.
FilePayloadClassRepresents a file to be uploaded via a file chooser.
GeolocationClassRepresents a geographic location.
HttpCredentialsClassCredentials for HTTP authentication.
IAccessibilityReporterInterfaceOpt-in interface for reporters that want to receive accessibility violation events. Reporters implement both IReporter and IAccessibilityReporter to receive violations alongside normal test lifecycle events.
IAccessibilityRuleInterfaceEvaluates a single accessibility rule against one node in the accessibility tree.
IBrowserInterfaceRepresents a browser instance. A browser can have multiple contexts.
IBrowserContextInterfaceRepresents an isolated browser context with its own cookies, cache, and storage.
IBrowserLeaseInterfaceA leased browser instance. Disposing the lease returns the browser to the pool.
IBrowserPoolInterfaceManages a pool of browser instances for concurrent test execution.
ICoverageReporterInterfaceOpt-in reporter interface for receiving JavaScript and CSS code coverage data collected during test execution. Reporters implement both IReporter and ICoverageReporter to receive coverage events. Separate from IReporter to avoid default interface methods, which conflict with NativeAOT trimming.
IDialogInterfaceRepresents a JavaScript dialog (alert, confirm, prompt, or beforeunload).
IDownloadInterfaceRepresents a file download initiated by a page.
IElementHandleInterfaceRepresents a handle to a DOM element in the page. Prefer ILocator for most use cases.
IFileChooserInterfaceRepresents a file chooser dialog opened by the page.
IFrameInterfaceRepresents a frame within a page (including the main frame).
IHeaderCollectionInterfaceRepresents a read-only collection of HTTP headers.
IJSHandleInterfaceRepresents a handle to a JavaScript object in the page.
IKeyboardInterfaceProvides methods for keyboard input.
ILifecycleHookInterfaceHooks into the browser automation lifecycle for cross-cutting concerns (logging, performance measurement, automatic retries).
ILocatorInterfaceRepresents a way to find elements on a page. Locators are strict by default and will throw if multiple elements match.
IMotusLoggerInterfaceSimple logging interface for Motus plugins. Keeps the abstractions package dependency-free.
IMouseInterfaceProvides methods for mouse input.
IPageInterfaceRepresents a single browser page (tab). Provides methods for navigation, interaction, evaluation, and more.
IPerformanceReporterInterfaceOpt-in reporter interface for receiving performance metrics collected during test execution. Reporters implement both IReporter and IPerformanceReporter to receive performance events. Separate from IReporter to avoid default interface methods, which conflict with NativeAOT trimming.
IPluginInterfaceBase interface for all Motus plugins.
IPluginContextInterfaceProvides services to plugins during initialization for registering custom extensions.
IReporterInterfaceCaptures and reports test execution results. Multiple reporters can be active simultaneously.
IRequestInterfaceRepresents an HTTP request sent by the page.
IResponseInterfaceRepresents an HTTP response received by the page.
IRouteInterfaceRepresents an intercepted network route that can be fulfilled, continued, or aborted.
ISelectorStrategyInterfaceDefines a custom element-targeting strategy beyond the built-in CSS, XPath, and text selectors.
ITouchscreenInterfaceProvides methods for touchscreen input.
ITracingInterfaceProvides tracing capabilities for recording browser actions.
IVideoInterfaceRepresents a video recording of page actions.
IWaitConditionInterfaceDefines a custom wait condition that can be used with the WaitForAsync API.
KeyboardPressOptionsClassOptions for keyboard press operations.
KeyboardTypeOptionsClassOptions for keyboard type operations.
KeyModifierEnumModifier keys that can be held during keyboard and mouse actions.
LaunchOptionsClassOptions for launching a browser instance.
LayoutShiftEntryClassAn individual layout shift entry observed during page execution.
LoadStateEnumSpecifies the page load state to wait for.
LocatorOptionsClassOptions for creating a locator.
MotusAssertionExceptionClassThrown when a test assertion made through the Motus assertion API fails.
MotusExceptionClassBase exception for all Motus engine errors. Provides an optional screenshot captured at the time of failure for diagnostics.
MotusNavigationExceptionClassThrown when a page navigation fails with an error (e.g. DNS resolution failure).
MotusPluginAttributeClassMarks a class as a Motus plugin entry point. The Motus source generator scans for this attribute to produce plugin registration code at compile time.
MotusProtocolExceptionClassThrown when the CDP protocol layer returns an error or fails to communicate.
MotusSelectorExceptionClassBase exception for selector-related errors.
MotusTargetClosedExceptionClassThrown when the browser target (page, frame, worker) has been closed or destroyed.
MotusTimeoutExceptionClassThrown when an operation exceeds its configured timeout.
MouseButtonEnumSpecifies which mouse button to use for mouse actions.
MouseButtonOptionsClassOptions for mouse button operations.
MouseMoveOptionsClassOptions for mouse move operations.
NavigationOptionsClassOptions for page navigation operations.
NavigationTimeoutExceptionClassThrown when a page navigation exceeds its timeout.
OriginalFileCoverageClassCoverage attributed to an original (pre-bundle) source file resolved through a JavaScript/CSS source map. Populated when a generated asset references a parseable source map; otherwise the asset's coverage is reported only via ScriptCoverage / StylesheetCoverage.
OriginStorageClassRepresents local storage entries for a specific origin.
PageErrorEventArgsClassEvent arguments for uncaught exceptions in the page.
PerformanceBudgetClassDefines performance budget thresholds. Only non-null metrics are enforced.
PerformanceBudgetAttributeClassDeclares performance budget thresholds for a test method or class. Only specified metrics (values >= 0) are enforced. Method-level attributes override class-level attributes.
PerformanceBudgetEntryClassA single metric evaluation within a performance budget check.
PerformanceBudgetResultClassThe result of evaluating a PerformanceBudget against collected metrics.
PerformanceMetricsClassCore Web Vitals and supplementary performance metrics collected during test execution.
PerformanceOptionsClassConfiguration for the built-in performance metrics collector hook.
PluginDiscoveryClassBridge for source-generated plugin registration. Do not call directly.
ProxySettingsClassProxy server configuration.
QuarantineAttributeClassMarks a test (or every test in a class) as quarantined. A quarantined test still runs, but its failures do not fail the run: it is reported in a separate bucket and excluded from the exit code. Use this to keep a known-flaky test running and visible while it is being stabilized, instead of deleting or skipping it.
RecordVideoOptionsClassOptions for recording video of page actions.
RequestEventArgsClassEvent arguments for network request events.
ResponseEventArgsClassEvent arguments for network response events.
RouteContinueOptionsClassOptions for continuing an intercepted route with modifications.
RouteFulfillOptionsClassOptions for fulfilling a route with a custom response.
SameSiteAttributeEnumSpecifies the SameSite attribute for cookies.
ScreenshotOptionsClassOptions for taking a screenshot.
ScreenshotTypeEnumSpecifies the image format for screenshots.
ScriptCoverageClassJavaScript coverage data for a single script URL, aggregated across all sessions.
StorageStateClassRepresents the complete storage state of a browser context including cookies and local storage.
StylesheetCoverageClassCSS coverage data for a single stylesheet URL, aggregated across all sessions. Note: Source is included beyond the spec because line-level computation requires the source text.
TestInfoClassMetadata for an individual test, passed to the reporter when a test begins.
TestResultClassThe outcome of an individual test, passed to the reporter when a test ends.
TestRunSummaryClassAggregate results for a completed test run, passed to the reporter at the end of a run.
TestSuiteInfoClassMetadata for a test suite run, passed to the reporter when a run begins.
TracingStartOptionsClassOptions for starting a trace.
TracingStopOptionsClassOptions for stopping a trace.
ViewportSizeClassRepresents the viewport dimensions.
WaitConditionOptionsClassOptions that control how a wait condition is evaluated.
WaitTimeoutExceptionClassThrown when a wait condition (WaitForAsync, WaitForCondition, WaitForURL) exceeds its timeout.
WaitUntilEnumSpecifies when a navigation is considered complete.

Motus.Recorder

Session recording and code generation: capturing browser interactions, inferring selectors for them, and emitting test code and Page Object Model classes. 27 public types. View on NuGet.

Motus.Recorder

TypeDescription
IActionCaptureEngineInterfaceCaptures browser interactions and produces a stream of ResolvedAction objects.

Motus.Recorder.ActionCapture

TypeDescription
ActionCaptureEngineClassOrchestrates the action capture pipeline: JS injection, CDP event subscriptions, the Motus.Recorder.ActionCapture.InputStateMachine for debouncing/grouping, and selector inference.
ActionCaptureOptionsClassConfiguration for the action capture engine.

Motus.Recorder.CodeEmit

TypeDescription
CodeEmitOptionsClassConfiguration for CodeEmitter.
CodeEmitterClassConverts a sequence of ResolvedAction into compilable C# test code.
EmitResultClassThe output of a CodeEmitter call: the generated C# source plus metadata about each locator call in the source (for manifest emission).
EmittedLocatorClassMetadata about a single locator call emitted into generated test/POM source, used by selector manifest emission to map each locator to its source line.

Motus.Recorder.PageAnalysis

TypeDescription
DiscoveredElementClassPairs a discovered page element with its inferred selector and derived C# member name.
PageAnalysisEngineClassCrawls a live page's DOM to discover interactive elements, infers selectors, and derives C# member names for POM generation.
PageAnalysisOptionsClassConfiguration for PageAnalysisEngine.
PageClassNameDeriverClassConverts a URL into a valid C# class name for POM generation.
PageElementInfoClassRaw element data returned by the DOM crawl JavaScript evaluation.

Motus.Recorder.PomEmit

TypeDescription
PomEmitOptionsClassConfiguration for PomEmitter.
PomEmitResultClassThe output of a PomEmitter call: the generated C# source plus metadata about each locator property (for manifest emission).
PomEmitterClassEmits a strongly-typed C# partial class (Page Object Model) from discovered page elements.

Motus.Recorder.Records

TypeDescription
ActionRecordClassBase record for all captured browser actions.
CheckActionClassA checkbox or radio button change.
ClickActionClassA mouse click action (mousedown + mouseup within threshold).
DialogActionClassA JavaScript dialog (alert, confirm, prompt, beforeunload).
FileUploadActionClassA file upload triggered by a file chooser dialog.
FillActionClassA text input action (debounced from rapid keystroke input events).
KeyPressActionClassA non-printable key press (not part of an active fill).
NavigationActionClassA page navigation event (main frame only).
ResolvedActionClassWraps an ActionRecord with the inferred selector for its target element. Selector is null when inference fails or the action type needs no selector (navigation, keyboard, scroll, dialog).
ScrollActionClassA scroll action (debounced from rapid scroll events).
SelectActionClassA select element change (one or more options selected).

Motus.Recorder.SelectorInference

TypeDescription
SelectorInferenceOptionsClassConfiguration for Motus.Recorder.SelectorInference.SelectorInferenceEngine.

Motus.Testing

The shared browser fixture and failure-tracing helper that the three test framework integrations build on. 2 public types. View on NuGet.

TypeDescription
BrowserFixtureClassManages a single browser instance for use in test fixtures. Call InitializeAsync(LaunchOptions) once (typically in assembly/collection setup), then create isolated contexts per test via NewContextAsync(ContextOptions). If the browser crashes or becomes unresponsive, the fixture automatically restarts Chrome so subsequent tests proceed against a fresh browser.
FailureTracingClassManages automatic trace capture around test execution. When failure.trace is enabled in motus.config.json or via the MOTUS_FAILURES_TRACE environment variable, tracing is started before the test and saved to disk only when the test fails.

Motus.Testing.MSTest

MSTest integration: a base test class giving each test its own browser context, and the attributes that hook it into the MSTest lifecycle. 3 public types. View on NuGet.

TypeDescription
MotusTestBaseClassBase class for MSTest browser tests. Shares a single browser across all tests in the assembly and creates an isolated context per test. Compatible with [Parallelize].
MotusTestClassAttributeClassA test class whose tests survive the browser going away, in place of [TestClass].
MotusTestMethodAttributeClassA test method that is run again when the browser goes away underneath it.

Motus.Testing.NUnit

NUnit integration: a base test class compatible with parallel test execution. 1 public type. View on NuGet.

TypeDescription
MotusTestBaseClassBase class for NUnit browser tests. Launches a browser per fixture and creates an isolated context per test. Compatible with [Parallelizable(ParallelScope.All)].

Motus.Testing.xUnit

xUnit integration: the collection definition and the class and shared fixtures for parallel test execution. 3 public types. View on NuGet.

TypeDescription
BrowserContextFixtureClassxUnit class fixture that creates an isolated browser context and page per test class. Requires SharedBrowserFixture via collection fixture injection. Note: Automatic failure tracing is not supported for xUnit class fixtures because xUnit does not expose per-test outcome in DisposeAsync. Use Context.Tracing.StartAsync / StopAsync manually for per-test traces.
MotusCollectionClassxUnit collection definition that shares a single browser across all test classes decorated with [Collection(nameof(MotusCollection))].
SharedBrowserFixtureClassxUnit collection fixture that manages a shared browser instance. Use with MotusCollection to share a single browser across test classes.