Table of Contents

Additional Modules

This guide provides an overview of the specialized modules in WebDriverBiDi.NET. Most of them implement W3C specifications that extend the core WebDriver BiDi protocol; the WebExtension module is defined by the core specification itself.

Overview

WebDriverBiDi.NET includes support for the core specification's WebExtension module and for several W3C specifications that extend the WebDriver BiDi protocol. All module commands accept optional timeoutOverride and CancellationToken parameters—see the API Design Guide for details.

Permissions Module

The Permissions module allows you to manage browser permissions for features like geolocation, notifications, and camera access.

Quick Example

// Grant geolocation permission
SetPermissionCommandParameters parameters =
    new SetPermissionCommandParameters(
        new PermissionDescriptor("geolocation"),
        PermissionState.Granted,
        "https://example.org");

await driver.Permissions.SetPermissionAsync(parameters);

View full Permissions module documentation →

Bluetooth Module

The Bluetooth module provides control over the Web Bluetooth API for testing Bluetooth-enabled web applications.

Quick Example

// Simulate a Bluetooth device
SimulatePreconnectedPeripheralCommandParameters parameters =
    new SimulatePreconnectedPeripheralCommandParameters(
        contextId,
        "AA:BB:CC:DD:EE:FF",
        "Heart Rate Monitor"
    );

await driver.Bluetooth.SimulatePreconnectedPeripheralAsync(parameters);

Note: Bluetooth module support varies by browser and requires specific browser flags to be enabled.

View full Bluetooth module documentation →

WebExtension Module

The WebExtension module allows you to manage browser extensions programmatically.

Quick Example

// Install an extension
InstallCommandParameters parameters = new InstallCommandParameters(
    new ExtensionArchivePath("/path/to/extension.zip")
);

InstallCommandResult result = await driver.WebExtension.InstallAsync(parameters);
string extensionId = result.ExtensionId;

Console.WriteLine($"Extension installed: {extensionId}");

Note: Extension installation support varies by browser. The protocol takes a zip archive or an unpacked directory, not a browser-specific package such as a .crx or .xpi.

View full WebExtension module documentation →

Speculation Module

The Speculation module provides monitoring of prefetch status updates. It exposes the speculation.prefetchStatusUpdated event defined in the Prefetch spec's Automated testing section. WebDriver BiDi does not define commands to add or remove speculation rules—those are configured by the page via the Speculation Rules API.

Quick Example

driver.Speculation.OnPrefetchStatusUpdated.AddObserver((e) =>
{
    Console.WriteLine($"Prefetch {e.Url}: {e.Status}");
});

SubscribeCommandParameters subscribe = new SubscribeCommandParameters(
    driver.Speculation.OnPrefetchStatusUpdated.EventName);
await driver.Session.SubscribeAsync(subscribe);

Note: Prefetch status events are experimental and may not be available in all browsers.

View full Speculation module documentation →

User Agent Client Hints Module

The User Agent Client Hints module allows you to override user agent client hints in the browser, enabling responsive design and feature detection testing without relying solely on the User-Agent string.

Quick Example

// Override client hints for cross-browser brand testing
SetClientHintsOverrideCommandParameters parameters = new SetClientHintsOverrideCommandParameters();
parameters.ClientHints = new ClientHintsMetadata
{
    Brands = new List<BrandVersion>
    {
        new BrandVersion("Chromium", "120.0"),
        new BrandVersion("Google Chrome", "120.0")
    },
    Platform = "Windows",
    PlatformVersion = "10.0",
    Architecture = "x86",
    Mobile = false
};

await driver.UserAgentClientHints.SetClientHintsOverrideAsync(parameters);

Note: User Agent Client Hints support varies by browser. This module complements the Emulation Module for user agent string overrides.

View full User Agent Client Hints module documentation →

Digital Credentials Module

The Digital Credentials module allows you to simulate a virtual digital wallet, enabling automated testing of credential presentation flows without a real wallet application.

Quick Example

Dictionary<string, object?> credentialResponse = new Dictionary<string, object?>
{
    ["token"] = "eyJhbGciOiJFUzI1NiJ9...",
    ["format"] = "jwt_vc"
};

SetVirtualWalletBehaviorCommandParameters @params = new SetVirtualWalletBehaviorCommandParameters(
    VirtualWalletAction.Respond)
{
    Protocol = "openid4vp-v1-unsigned",
    Response = credentialResponse
};

await driver.DigitalCredentials.SetVirtualWalletBehaviorAsync(@params);
Console.WriteLine("Virtual wallet will return the predefined credential response");

Note: The Digital Credentials API and its WebDriver BiDi automation support are experimental and may not be available in all browsers.

View full Digital Credentials module documentation →

Module Availability

Module Chrome/Edge Firefox Safari
Permissions ✅ ✅ ⚠️ Limited
Bluetooth ⚠️ Experimental ❌ ❌
WebExtension ✅ ⚠️ Different API ⚠️ Limited
Speculation ⚠️ Experimental ❌ ❌
User Agent Client Hints ⚠️ Experimental ❌ ❌
Digital Credentials ⚠️ Experimental ❌ ❌

Getting Started

Each module has its own dedicated documentation page with comprehensive examples, best practices, and troubleshooting guides:

Next Steps

Further Reading