Implementation:SeleniumHQ Selenium HasFederatedCredentialManagement
| Knowledge Sources | |
|---|---|
| Domains | WebDriver, Federated_Credentials |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
HasFederatedCredentialManagement is a capability interface that WebDriver implementations can adopt to indicate support for interacting with FedCM (Federated Credential Management) dialogs, providing methods to control delay behavior, reset cooldowns, and access open dialogs.
Description
The HasFederatedCredentialManagement interface is annotated with @Beta, indicating it is part of the evolving FedCM WebDriver extension. It defines three methods:
setDelayEnabled(boolean enabled)-- controls whether FedCM's built-in promise rejection delay is active. FedCM intentionally delays promise resolution on failures for privacy reasons (to prevent timing attacks). Disabling this delay allows tests to run faster when privacy timing is not under test.resetCooldown()-- resets the FedCM dialog cooldown timer. When the account chooser is dismissed, the user agent may enforce a cooldown before the dialog can be triggered again. This method resets that cooldown so tests can immediately trigger a new dialog.getFederatedCredentialManagementDialog()-- returns the currently openFederatedCredentialManagementDialog, ornullif no dialog is open. This method is designed to be used withWebDriverWaitfor polling.
Usage
Use HasFederatedCredentialManagement when writing automated tests that exercise federated sign-in flows using the FedCM API. Cast the WebDriver instance to this interface to access FedCM-specific functionality. This interface is typically implemented by browser drivers that support the FedCM WebDriver extension (e.g., Chrome, Edge).
Code Reference
Source Location
- Repository: SeleniumHQ_Selenium
- File: java/src/org/openqa/selenium/federatedcredentialmanagement/HasFederatedCredentialManagement.java
Signature
@Beta
@NullMarked
public interface HasFederatedCredentialManagement {
void setDelayEnabled(boolean enabled);
void resetCooldown();
@Nullable FederatedCredentialManagementDialog getFederatedCredentialManagementDialog();
}
Import
import org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement;
I/O Contract
Methods
| Method | Return Type | Description |
|---|---|---|
setDelayEnabled(boolean enabled) |
void |
Enables or disables the FedCM promise rejection delay; disabling speeds up test execution for failure scenarios |
resetCooldown() |
void |
Resets the dialog cooldown so the FedCM dialog can be triggered again immediately after dismissal |
getFederatedCredentialManagementDialog() |
@Nullable FederatedCredentialManagementDialog |
Returns the currently open FedCM dialog, or null if none is open
|
setDelayEnabled Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled |
boolean |
Yes | true to enable the standard privacy delay; false to disable it for faster test execution
|
Usage Examples
// Cast the driver to access FedCM capabilities
HasFederatedCredentialManagement fedCmDriver =
(HasFederatedCredentialManagement) driver;
// Disable the promise rejection delay for faster tests
fedCmDriver.setDelayEnabled(false);
// Navigate to a page that triggers a FedCM flow
driver.get("https://example.com/fedcm-login");
// Wait for the FedCM dialog to appear
FederatedCredentialManagementDialog dialog =
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(d -> ((HasFederatedCredentialManagement) d)
.getFederatedCredentialManagementDialog());
// Interact with the dialog
List<FederatedCredentialManagementAccount> accounts = dialog.getAccounts();
dialog.selectAccount(0);
// Reset cooldown before triggering another dialog
fedCmDriver.resetCooldown();
// Trigger another FedCM flow
driver.get("https://example.com/another-fedcm-login");
FederatedCredentialManagementDialog secondDialog =
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(d -> ((HasFederatedCredentialManagement) d)
.getFederatedCredentialManagementDialog());
secondDialog.cancelDialog();
Related Pages
- FederatedCredentialManagementDialog -- the dialog interface returned by
getFederatedCredentialManagementDialog() - FederatedCredentialManagementAccount -- data class for accounts within FedCM dialogs
- Interface Segregation -- FedCM capability is an optional interface, not part of the core WebDriver API
- Capability Detection -- drivers expose FedCM support via interface implementation, enabling
instanceofchecks