From fb954063bfc6c299fb70a560d22eb7880b87f9dc Mon Sep 17 00:00:00 2001 From: Daniel Garnier-Moiroux Date: Fri, 13 Dec 2024 10:49:35 +0100 Subject: [PATCH] Fix WebAuthnWebdriverTests Closes gh-16279 --- .../annotation/configurers/WebAuthnWebDriverTests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/src/integration-test/java/org/springframework/security/config/annotation/configurers/WebAuthnWebDriverTests.java b/config/src/integration-test/java/org/springframework/security/config/annotation/configurers/WebAuthnWebDriverTests.java index e02440517d..075856f3a4 100644 --- a/config/src/integration-test/java/org/springframework/security/config/annotation/configurers/WebAuthnWebDriverTests.java +++ b/config/src/integration-test/java/org/springframework/security/config/annotation/configurers/WebAuthnWebDriverTests.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -67,7 +66,6 @@ * * @author Daniel Garnier-Moiroux */ -@Disabled class WebAuthnWebDriverTests { private String baseUrl; @@ -194,6 +192,11 @@ void loginWhenAuthenticatorRegisteredThenSuccess() { this.driver.findElement(passkeyLabel()).sendKeys("Virtual authenticator"); this.driver.findElement(registerPasskeyButton()).click(); + // Ensure the page location has changed before performing further assertions. + // This is required because the location change is asynchronously performed in + // javascript, and performing assertions based on this.driver.findElement(...) + // may result in a StaleElementReferenceException. + await(() -> assertThat(this.driver.getCurrentUrl()).endsWith("/webauthn/register?success")); await(() -> assertHasAlertStartingWith("success", "Success!")); List passkeyRows = this.driver.findElements(passkeyTableRows());