diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java index b21717bed93..8ef9aacfb33 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java @@ -135,13 +135,17 @@ public final class WaitUtils { // Ensure the URL is "stable", i.e. is not changing anymore; if it'd changing, some redirects are probably still in progress for (int maxRedirects = 4; maxRedirects > 0; maxRedirects--) { - currentUrl = driver.getCurrentUrl(); - FluentWait wait = new FluentWait<>(driver).withTimeout(Duration.ofMillis(250)); try { + currentUrl = driver.getCurrentUrl(); + FluentWait wait = new FluentWait<>(driver).withTimeout(Duration.ofMillis(250)); wait.until(not(urlToBe(currentUrl))); - } - catch (TimeoutException e) { - break; // URL has not changed recently - ok, the URL is stable and page is current + } catch (TimeoutException e) { + if (driver.getPageSource() != null) { + break; // URL has not changed recently - ok, the URL is stable and page is current + } + } catch (Exception e) { + log.warnf("Unknown exception thrown waiting stabilization of the URL: %s", e.getMessage()); + pause(250); } if (maxRedirects == 1) { log.warn("URL seems unstable! (Some redirect are probably still in progress)");