Implementation:SeleniumHQ Selenium FederatedCredentialManagementDialog
| Knowledge Sources | |
|---|---|
| Domains | WebDriver, Federated_Credentials |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
FederatedCredentialManagementDialog is an interface representing an open FedCM (Federated Credential Management) dialog in the browser, providing methods to inspect, interact with, and dismiss the dialog during automated testing.
Description
The FederatedCredentialManagementDialog interface models a currently open FedCM dialog, as specified by the W3C FedCM API. It provides methods to:
- Cancel the dialog -- simulates the user clicking the close/X button.
- Select an account -- simulates the user clicking on an account in the account chooser, identified by index.
- Click the dialog -- triggers a click action on the dialog.
- Inspect dialog properties -- retrieve the dialog type (account chooser or auto-reauthentication), title, and subtitle.
- Retrieve account list -- get the list of
FederatedCredentialManagementAccountobjects shown in the dialog.
Two dialog type constants are defined:
DIALOG_TYPE_ACCOUNT_LIST("AccountChooser") -- the user is presented with a list of accounts to choose from.DIALOG_TYPE_AUTO_REAUTH("AutoReauthn") -- the browser is automatically re-authenticating with a previously used account.
Usage
Use FederatedCredentialManagementDialog to interact with FedCM dialogs in end-to-end tests that exercise federated authentication flows. Obtain the dialog instance via HasFederatedCredentialManagement.getFederatedCredentialManagementDialog(), typically inside a WebDriverWait to wait for the dialog to appear.
Code Reference
Source Location
- Repository: SeleniumHQ_Selenium
- File: java/src/org/openqa/selenium/federatedcredentialmanagement/FederatedCredentialManagementDialog.java
Signature
@NullMarked
public interface FederatedCredentialManagementDialog {
String DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser";
String DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn";
void cancelDialog();
void selectAccount(int index);
@Nullable String getDialogType();
@Nullable String getTitle();
@Nullable String getSubtitle();
void clickDialog();
List<FederatedCredentialManagementAccount> getAccounts();
}
Import
import org.openqa.selenium.federatedcredentialmanagement.FederatedCredentialManagementDialog;
I/O Contract
Constants
| Constant | Value | Description |
|---|---|---|
DIALOG_TYPE_ACCOUNT_LIST |
"AccountChooser" |
Dialog presents a list of accounts for the user to choose from |
DIALOG_TYPE_AUTO_REAUTH |
"AutoReauthn" |
Dialog is auto-reauthenticating with a previously used account |
Methods
| Method | Return Type | Description |
|---|---|---|
cancelDialog() |
void |
Closes the dialog as if the user clicked the X/close button |
selectAccount(int index) |
void |
Selects an account by its index in the list returned by getAccounts()
|
getDialogType() |
@Nullable String |
Returns the dialog type: one of DIALOG_TYPE_ACCOUNT_LIST or DIALOG_TYPE_AUTO_REAUTH
|
getTitle() |
@Nullable String |
Returns the title text of the dialog |
getSubtitle() |
@Nullable String |
Returns the subtitle text of the dialog, or null if none
|
clickDialog() |
void |
Triggers a click action on the dialog |
getAccounts() |
List<FederatedCredentialManagementAccount> |
Returns the accounts shown in the dialog; for auto-reauth dialogs, returns the single account being signed in |
selectAccount Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
index |
int |
Yes | Zero-based index of the account to select from the list returned by getAccounts()
|
Usage Examples
// Wait for a FedCM dialog and interact with it
HasFederatedCredentialManagement fedCmDriver =
(HasFederatedCredentialManagement) driver;
FederatedCredentialManagementDialog dialog =
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(d -> fedCmDriver.getFederatedCredentialManagementDialog());
// Check the dialog type
String dialogType = dialog.getDialogType();
if (FederatedCredentialManagementDialog.DIALOG_TYPE_ACCOUNT_LIST.equals(dialogType)) {
// Account chooser dialog - select the first account
List<FederatedCredentialManagementAccount> accounts = dialog.getAccounts();
assertFalse(accounts.isEmpty());
dialog.selectAccount(0);
} else if (FederatedCredentialManagementDialog.DIALOG_TYPE_AUTO_REAUTH.equals(dialogType)) {
// Auto-reauthentication - verify the account
FederatedCredentialManagementAccount account = dialog.getAccounts().get(0);
assertEquals("user@example.com", account.getEmail());
}
// Inspect dialog metadata
System.out.println("Title: " + dialog.getTitle());
System.out.println("Subtitle: " + dialog.getSubtitle());
// Cancel/dismiss the dialog
dialog.cancelDialog();
Related Pages
- FederatedCredentialManagementAccount -- data class for accounts shown in the dialog
- HasFederatedCredentialManagement -- interface to obtain dialog instances from a driver
- Interface Segregation -- dialog interaction is separated into its own interface
- Command Pattern -- dialog actions (cancel, select, click) are discrete operations