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 VirtualAuthenticator

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

Overview

The VirtualAuthenticator interface represents a virtual WebAuthn authenticator instance that can manage credentials and simulate user verification for automated testing.

Description

VirtualAuthenticator is an interface that models a W3C WebAuthn virtual authenticator. It provides methods to manage the authenticator's lifecycle including adding, retrieving, and removing credentials, as well as controlling user verification state. Instances are created through HasVirtualAuthenticator.addVirtualAuthenticator() and each authenticator has a unique identifier.

Usage

Use VirtualAuthenticator to programmatically manage WebAuthn credentials during automated browser tests. After obtaining an authenticator instance from the driver, inject pre-configured credentials, query existing credentials, or control whether user verification succeeds or fails.

Code Reference

Source Location

Signature

public interface VirtualAuthenticator {
    String getId();
    void addCredential(Credential credential);
    List<Credential> getCredentials();
    void removeCredential(byte[] credentialId);
    void removeCredential(String credentialId);
    void removeAllCredentials();
    void setUserVerified(boolean verified);
}

Import

import org.openqa.selenium.virtualauthenticator.VirtualAuthenticator;

I/O Contract

Methods

Method Parameters Returns Description
getId() none String Returns the unique identifier of this virtual authenticator
addCredential Credential credential void Injects a credential into the authenticator
getCredentials() none List<Credential> Returns the list of all credentials owned by this authenticator
removeCredential(byte[]) byte[] credentialId void Removes a credential by its raw byte array ID
removeCredential(String) String credentialId void Removes a credential by its Base64 URL-encoded string ID
removeAllCredentials() none void Removes all credentials from this authenticator
setUserVerified boolean verified void Controls whether the authenticator simulates successful or failed user verification

Usage Examples

// Obtain authenticator from driver
VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions()
    .setProtocol(VirtualAuthenticatorOptions.Protocol.CTAP2)
    .setHasResidentKey(true)
    .setHasUserVerification(true);
VirtualAuthenticator authenticator = ((HasVirtualAuthenticator) driver)
    .addVirtualAuthenticator(options);

// Get the authenticator ID
String authId = authenticator.getId();

// Add a credential
authenticator.addCredential(credential);

// List all credentials
List<Credential> credentials = authenticator.getCredentials();

// Remove a specific credential by byte array ID
authenticator.removeCredential(credential.getId());

// Or remove by Base64 URL-encoded string ID
authenticator.removeCredential("dGVzdA==");

// Remove all credentials
authenticator.removeAllCredentials();

// Simulate user verification failure
authenticator.setUserVerified(false);

Related Pages

Page Connections

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