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 operationsModule- Base class for all protocol modulesCommandParameters- Base class for command parametersCommandResult- Base class for command resultsObservableEvent<T>- Event subscription and notificationEventObserver<T>- Event observation and synchronization
WebDriverBiDi.Browser
Browser-level operations including user context and window management.
Key Classes:
BrowserModule- Browser module implementationClientWindowInfo- Browser window informationUserContextInfo- User context information
WebDriverBiDi.BrowsingContext
Tab, window, and iframe management, navigation, and page interaction.
Key Classes:
BrowsingContextModule- Browsing context module implementationBrowsingContextInfo- Browsing context informationNavigateCommandParameters- Navigation parametersNavigateCommandResult- Navigation resultsCaptureScreenshotCommandParameters- Screenshot parametersSetViewportCommandParameters- Viewport size and device pixel ratio settings
WebDriverBiDi.Script
JavaScript execution, preload scripts, and value marshalling.
Key Classes:
ScriptModule- Script module implementationEvaluateCommandParameters- Script evaluation parametersCallFunctionCommandParameters- Function call parametersRemoteValue- JavaScript value from browserLocalValue- JavaScript value to browserAddPreloadScriptCommandParameters- Preload script parameters
WebDriverBiDi.Network
Network traffic monitoring, interception, and modification.
Key Classes:
NetworkModule- Network module implementationRequestData- HTTP request informationResponseData- HTTP response informationAddInterceptCommandParameters- Network intercept parametersProvideResponseCommandParameters- Custom response parameters
WebDriverBiDi.Input
User input simulation including mouse, keyboard, touch, and wheel events.
Key Classes:
InputModule- Input module implementationPerformActionsCommandParameters- Action parametersPointerSourceActions- Mouse/touch action sourceKeySourceActions- Keyboard action source
WebDriverBiDi.Log
Console log and browser error monitoring.
Key Classes:
LogModule- Log module implementationLogEntry- Log entry base classConsoleLogEntry- Console log entryEntryAddedEventArgs- Log entry event arguments
WebDriverBiDi.Session
Session management and event subscriptions.
Key Classes:
SessionModule- Session module implementationSubscribeCommandParameters- Subscription parametersStatusCommandParameters- Status check parameters
WebDriverBiDi.Storage
Cookie and storage management.
Key Classes:
StorageModule- Storage module implementationGetCookiesCommandParameters- Cookie retrieval parametersSetCookieCommandParameters- Cookie setting parametersPartialCookie- 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 aConnection(WebSocket or pipe)Command- Command representationMessage- 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 theTransportto connect to it;BrowserLauncher.Configurereturns aBrowserLauncherBuilderBrowserInstance- A launched browser, which closes it when disposedBrowserLocator/DriverLocator- Find or download a browser or driver without launching itBrowserDownloadOptions- The cache directory, download sources, and mirror manifestRemoteGridOptions- Capabilities and headers for a session on a remote gridChromiumTransport- ATransportthat 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 asNavigateAsync(contextId, url)andCaptureScreenshotAsyncreturning bytesInputBuilder- Buildsinput.performActionssequences tick by tick, withInputBuilderExtensionsfor clicks, typing, chords, drag-and-drop, and scrolling;Keysnames the special keysNetworkTrafficMonitor- Captures requests, responses, and bodies, optionally modifying requests and answering authentication challenges; configured withNetworkTrafficMonitorOptionsNetworkRequest- A captured request and its outcomeHarGenerator- Writes captured traffic as an HTTP Archive (HAR 1.2)ScriptException- Thrown when a script called throughCallFunctionAsyncthrows
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
ConfigureAwaitusage in library code
Error Handling
- Command errors throw
WebDriverBiDiCommandException - Timeouts throw
WebDriverBiDiTimeoutException - Protocol errors (error responses matching no pending command) surface as
WebDriverBiDiProtocolException, routed throughUnexpectedErrorBehavior - 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:
- Check the XML comments in the source code
- Submit an issue on GitHub
- Submit a pull request with improvements