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 FederatedCredentialManagementDialog

From Leeroopedia
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 FederatedCredentialManagementAccount objects 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

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

Page Connections

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