Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public interface FederatedCredentialManagementDialog {
String DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser";
String DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn";

String BUTTON_CONFIRM_IDP_LOGIN_CONTINUE = "ConfirmIdpLoginContinue";
// The following buttons need an account index.
String BUTTON_TERMS_OF_SERVICE = "TermsOfService";
String BUTTON_PRIVACY_POLICY = "PrivacyPolicy";

/** Closes the dialog as if the user had clicked X. */
void cancelDialog();

Expand Down Expand Up @@ -60,4 +65,19 @@ public interface FederatedCredentialManagementDialog {
* <p>If this is an auto reauth dialog, returns the single account that is being signed in.
*/
List<FederatedCredentialManagementAccount> getAccounts();

/**
* Clicks a button on the dialog.
*
* @param button The button to click.
*/
void clickButton(String button);

/**
* Clicks a button on the dialog that requires an account index.
*
* @param button The button to click.
* @param index The account index, if needed by the specified button.
*/
void clickButton(String button, int index);
}
11 changes: 11 additions & 0 deletions java/src/org/openqa/selenium/remote/FedCmDialogImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@ public List<FederatedCredentialManagementAccount> getAccounts() {
}
return accounts;
}

@Override
public void clickButton(String button) {
executeMethod.execute(DriverCommand.CLICK_DIALOG, Map.of("dialogButton", button));
}

@Override
public void clickButton(String button, int index) {
executeMethod.execute(
DriverCommand.CLICK_DIALOG, Map.of("dialogButton", button, "index", index));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,33 @@ void testGetAccounts() {
.isEqualTo("https://rp.example/terms_of_service.html");
assertThat(account2.getPrivacyPolicyUrl()).isEqualTo("https://rp.example/privacy_policy.html");
}

@Test
@NotYetImplemented(
value = CHROME,
reason = "https://github.com/SeleniumHQ/selenium/pull/12096#issuecomment-2017760822")
void testClickDialogButton() {
fedcmDriver.setDelayEnabled(false);
assertNull(fedcmDriver.getFederatedCredentialManagementDialog());

Object response = triggerFedCm();

waitForDialog();

FederatedCredentialManagementDialog dialog =
fedcmDriver.getFederatedCredentialManagementDialog();

assertEquals("Sign in to localhost with localhost", dialog.getTitle());
assertEquals("AccountChooser", dialog.getDialogType());

int windowCount = localDriver.getWindowHandles().size();
dialog.clickButton(dialog.BUTTON_PRIVACY_POLICY, 1);
WebDriverWait wait = new WebDriverWait(localDriver, Duration.ofSeconds(5));
wait.until(driver -> driver.getWindowHandles().size() > windowCount);

dialog.selectAccount(0);

response = jsAwareDriver.executeScript("return await promise");
assertThat(response).asInstanceOf(MAP).containsEntry("token", "a token");
}
}
Loading