Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:SeleniumHQ Selenium HasVirtualAuthenticator

From Leeroopedia
Knowledge Sources
Domains WebDriver, WebAuthn, VirtualAuthenticator
Last Updated 2026-02-12 00:00 GMT

Overview

The HasVirtualAuthenticator interface defines the contract for WebDriver implementations that support the W3C Virtual Authenticator API for WebAuthn testing.

Description

HasVirtualAuthenticator is a capability interface implemented by browser drivers that support creating and managing virtual authenticators. It provides two methods: one to add a virtual authenticator with specified options, and one to remove a previously added authenticator. This interface enables automated testing of WebAuthn/FIDO2 authentication flows without requiring physical security keys.

Usage

Use HasVirtualAuthenticator by casting a WebDriver instance to this interface when you need to set up or tear down virtual authenticators for WebAuthn testing. The driver must support the Virtual Authenticator protocol extension.

Code Reference

Source Location

Signature

public interface HasVirtualAuthenticator {
    VirtualAuthenticator addVirtualAuthenticator(VirtualAuthenticatorOptions options);
    void removeVirtualAuthenticator(VirtualAuthenticator authenticator);
}

Import

import org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator;

I/O Contract

Methods

Method Parameters Returns Description
addVirtualAuthenticator VirtualAuthenticatorOptions options VirtualAuthenticator Creates and registers a new virtual authenticator with the given configuration options. Returns the newly created authenticator instance.
removeVirtualAuthenticator VirtualAuthenticator authenticator void Removes a previously added virtual authenticator. The authenticator becomes invalid after removal and no further methods should be called on it.

Usage Examples

// Cast the driver to HasVirtualAuthenticator
HasVirtualAuthenticator authDriver = (HasVirtualAuthenticator) driver;

// Create options for the virtual authenticator
VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions()
    .setProtocol(VirtualAuthenticatorOptions.Protocol.CTAP2)
    .setTransport(VirtualAuthenticatorOptions.Transport.USB)
    .setHasResidentKey(true)
    .setHasUserVerification(true)
    .setIsUserVerified(true);

// Add a virtual authenticator
VirtualAuthenticator authenticator = authDriver.addVirtualAuthenticator(options);

// Perform WebAuthn operations...
authenticator.addCredential(credential);

// Clean up after testing
authDriver.removeVirtualAuthenticator(authenticator);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment