Table of Contents

API Reference

Welcome to the WebDriverBiDi.NET API reference documentation.

Overview

This section contains detailed API documentation for all public types, methods, and properties in WebDriverBiDi.NET. The documentation is automatically generated from XML comments in the source code.

Namespaces

WebDriverBiDi

The root namespace containing the main BiDiDriver class and core types.

Key Classes:

  • BiDiDriver - Main entry point for WebDriver BiDi operations
  • Module - Base class for all protocol modules
  • CommandParameters - Base class for command parameters
  • CommandResult - Base class for command results
  • ObservableEvent<T> - Event subscription and notification
  • EventObserver<T> - Event observation and synchronization

WebDriverBiDi.Browser

Browser-level operations including user context and window management.

Key Classes:

  • BrowserModule - Browser module implementation
  • ClientWindowInfo - Browser window information
  • UserContextInfo - User context information

WebDriverBiDi.BrowsingContext

Tab, window, and iframe management, navigation, and page interaction.

Key Classes:

  • BrowsingContextModule - Browsing context module implementation
  • BrowsingContextInfo - Browsing context information
  • NavigateCommandParameters - Navigation parameters
  • NavigateCommandResult - Navigation results
  • CaptureScreenshotCommandParameters - Screenshot parameters
  • SetViewportCommandParameters - Viewport size and device pixel ratio settings

WebDriverBiDi.Script

JavaScript execution, preload scripts, and value marshalling.

Key Classes:

  • ScriptModule - Script module implementation
  • EvaluateCommandParameters - Script evaluation parameters
  • CallFunctionCommandParameters - Function call parameters
  • RemoteValue - JavaScript value from browser
  • LocalValue - JavaScript value to browser
  • AddPreloadScriptCommandParameters - Preload script parameters

WebDriverBiDi.Network

Network traffic monitoring, interception, and modification.

Key Classes:

  • NetworkModule - Network module implementation
  • RequestData - HTTP request information
  • ResponseData - HTTP response information
  • AddInterceptCommandParameters - Network intercept parameters
  • ProvideResponseCommandParameters - Custom response parameters

WebDriverBiDi.Input

User input simulation including mouse, keyboard, touch, and wheel events.

Key Classes:

  • InputModule - Input module implementation
  • PerformActionsCommandParameters - Action parameters
  • PointerSourceActions - Mouse/touch action source
  • KeySourceActions - Keyboard action source

WebDriverBiDi.Log

Console log and browser error monitoring.

Key Classes:

  • LogModule - Log module implementation
  • LogEntry - Log entry base class
  • ConsoleLogEntry - Console log entry
  • EntryAddedEventArgs - Log entry event arguments

WebDriverBiDi.Session

Session management and event subscriptions.

Key Classes:

  • SessionModule - Session module implementation
  • SubscribeCommandParameters - Subscription parameters
  • StatusCommandParameters - Status check parameters

WebDriverBiDi.Storage

Cookie and storage management.

Key Classes:

  • StorageModule - Storage module implementation
  • GetCookiesCommandParameters - Cookie retrieval parameters
  • SetCookieCommandParameters - Cookie setting parameters
  • PartialCookie - Cookie definition

WebDriverBiDi.Emulation

Device and media emulation.

Key Classes:

  • EmulationModule - Emulation module implementation
  • Media feature emulation

WebDriverBiDi.Permissions

Browser permission management.

Key Classes:

  • PermissionsModule - Permissions module implementation
  • Permission descriptor types

WebDriverBiDi.Bluetooth

Web Bluetooth API control.

Key Classes:

  • BluetoothModule - Bluetooth module implementation

WebDriverBiDi.WebExtension

Browser extension management.

Key Classes:

  • WebExtensionModule - Web extension module implementation

WebDriverBiDi.Speculation

Navigation prefetching and speculation.

Key Classes:

  • SpeculationModule - Speculation module implementation

WebDriverBiDi.DigitalCredentials

Digital credentials API testing support (W3C Digital Credentials specification).

Key Classes:

  • DigitalCredentialsModule - Digital credentials module implementation

WebDriverBiDi.UserAgentClientHints

User agent client hints override for testing.

Key Classes:

  • UserAgentClientHintsModule - User agent client hints module implementation

WebDriverBiDi.Protocol

Low-level protocol communication types.

Key Classes:

  • Transport - Communication handler wrapping a Connection (WebSocket or pipe)
  • Command - Command representation
  • Message - Protocol message base class

WebDriverBiDi.Browsers

Locating, downloading, and launching browsers, from the WebDriverBiDi.Browsers package. See the Browser Setup Guide.

Key Classes:

  • BrowserLauncher - Starts a browser (directly, through its driver, or on a remote grid) and creates the Transport to connect to it; BrowserLauncher.Configure returns a BrowserLauncherBuilder
  • BrowserInstance - A launched browser, which closes it when disposed
  • BrowserLocator / DriverLocator - Find or download a browser or driver without launching it
  • BrowserDownloadOptions - The cache directory, download sources, and mirror manifest
  • RemoteGridOptions - Capabilities and headers for a session on a remote grid
  • ChromiumTransport - A Transport that speaks WebDriver BiDi to Chromium through its DevTools endpoint

WebDriverBiDi.Extensions

Conveniences over the protocol, from the WebDriverBiDi.Extensions package. Its types sit in the namespaces of the modules they extend. See the WebDriverBiDi.Extensions guide.

Key Classes:

  • SessionModuleExtensions, BrowsingContextModuleExtensions, ScriptModuleExtensions, InputModuleExtensions - One-call forms of common commands, such as NavigateAsync(contextId, url) and CaptureScreenshotAsync returning bytes
  • InputBuilder - Builds input.performActions sequences tick by tick, with InputBuilderExtensions for clicks, typing, chords, drag-and-drop, and scrolling; Keys names the special keys
  • NetworkTrafficMonitor - Captures requests, responses, and bodies, optionally modifying requests and answering authentication challenges; configured with NetworkTrafficMonitorOptions
  • NetworkRequest - A captured request and its outcome
  • HarGenerator - Writes captured traffic as an HTTP Archive (HAR 1.2)
  • ScriptException - Thrown when a script called through CallFunctionAsync throws

Using the API Reference

Generating Documentation

To generate the full API documentation locally:

# Install DocFX if not already installed
dotnet tool install -g docfx

# Build the library and the logging, browser management, and extensions packages in Release;
# docfx metadata reads the API surface from each one's bin/Release/netstandard2.0 directory
dotnet build src/WebDriverBiDi/WebDriverBiDi.csproj --configuration Release
dotnet build src/WebDriverBiDi.Logging/WebDriverBiDi.Logging.csproj --configuration Release
dotnet build src/WebDriverBiDi.Browsers/WebDriverBiDi.Browsers.csproj --configuration Release
dotnet build src/WebDriverBiDi.Extensions/WebDriverBiDi.Extensions.csproj --configuration Release

# Compile the documentation code samples (every [!code-csharp] region must compile)
dotnet build docs/code/WebDriverBiDi.DocSnippets.csproj --configuration Release

# Extract API metadata from XML comments, then generate the site
cd docs
docfx metadata docfx.json
docfx build docfx.json

# Serve locally
docfx serve _site

Then open your browser to http://localhost:8080.

Documentation Conventions

Command Parameters

All command parameter classes follow this pattern:

public class CommandNameCommandParameters : CommandParameters<CommandNameCommandResult>
{
    // Required parameters in constructor
    public CommandNameCommandParameters(string requiredParam)
    {
    }

    // Optional parameters as properties
    public string? OptionalParam { get; set; }

    public override string MethodName => "custom.moduleName";
}

Command Results

All command result classes follow this pattern:

public record CommandNameCommandResult : CommandResult
{
    // Properties are read-only (immutable)
    public string ResultProperty { get; }
}

Commands whose protocol result carries no data return EmptyResult. It is a CommandResult like any other, so extension properties the remote end supplied are still exposed, in the two places they can occupy: AdditionalData holds properties found inside the (otherwise empty) result object, and AdditionalResponseProperties holds properties found on the response envelope. The two positions are never merged, and neither stands in for the other.

Event Arguments

All event argument classes inherit from WebDriverBiDiEventArgs:

public record EventNameEventArgs : WebDriverBiDiEventArgs
{
    // Properties are read-only (immutable)
    public string EventData { get; }
}

Common Patterns in API

Async Methods

All methods that communicate with the browser are async:

public async Task<TResult> MethodNameAsync(TParameters parameters)

Module Access

All modules are accessed through the BiDiDriver:

BiDiDriver driver = new BiDiDriver();
BrowsingContextModule browsingContext = driver.BrowsingContext;
ScriptModule script = driver.Script;
NetworkModule network = driver.Network;

Event Subscription

Events use the observable pattern:

// Access observable event
ObservableEvent<TEventArgs> observableEvent = module.OnEventName;

// Add observer
EventObserver<TEventArgs> observer = observableEvent.AddObserver(handler);

// Subscribe through Session
await driver.Session.SubscribeAsync(subscribeParams);

API Design Principles

Immutability

  • Response objects are immutable - properties are read-only
  • Command parameters are mutable - properties are settable
  • This prevents accidental modification of data from the browser

Type Safety

  • Strong typing throughout the API
  • Generic type parameters for command/result correlation
  • Enumerations for fixed value sets

Async/Await

  • All I/O operations are asynchronous
  • No blocking operations
  • Proper ConfigureAwait usage in library code

Error Handling

  • Command errors throw WebDriverBiDiCommandException
  • Timeouts throw WebDriverBiDiTimeoutException
  • Protocol errors (error responses matching no pending command) surface as WebDriverBiDiProtocolException, routed through UnexpectedErrorBehavior
  • Script errors return EvaluateResultException

See Error Handling for the full exception hierarchy and when each type is thrown.

Examples

See the Examples section for practical usage of the API.

Contributing

If you find errors in the API documentation or have suggestions for improvements:

  1. Check the XML comments in the source code
  2. Submit an issue on GitHub
  3. Submit a pull request with improvements

Additional Resources