diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginPage.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginPage.java index ff406aea6d..04f7f90edc 100755 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginPage.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginPage.java @@ -22,6 +22,7 @@ import org.junit.Assert; import org.keycloak.common.util.Retry; import org.keycloak.testsuite.util.DroneUtils; import org.keycloak.testsuite.util.OAuthClient; +import org.keycloak.testsuite.util.UIUtils; import org.keycloak.testsuite.util.WaitUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -247,10 +248,7 @@ public class LoginPage extends LanguageComboboxAwarePage { } public void setRememberMe(boolean enable) { - boolean current = rememberMe.isSelected(); - if (current != enable) { - rememberMe.click(); - } + UIUtils.switchCheckbox(rememberMe, enable); } public boolean isRememberMeChecked() { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/UIUtils.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/UIUtils.java index 2d0841a161..cb6fe359e8 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/UIUtils.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/UIUtils.java @@ -1,6 +1,8 @@ package org.keycloak.testsuite.util; import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.keycloak.common.util.Retry; import org.keycloak.testsuite.page.AbstractPatternFlyAlert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -100,6 +102,28 @@ public final class UIUtils { performOperationWithPageReload(element::click); } + /** + * The method switches the checkbox to the expected state. + * + * It looks that since chrome 128, the single click sometimes does + * not work (See also similar issue {@link #clickLink(WebElement)}, so it is possible repeated multiple times until it reach + * the desired state + * + * @param checkbox Checkbox element to enable or disable + * @param enable If true, the checkbox should be switched to enabled (checked). If false, the checkbox should be switched to disabled (unchecked) + */ + public static void switchCheckbox(WebElement checkbox, boolean enable) { + int maxAttempts = 4; + + Retry.execute(() -> { + boolean current = checkbox.isSelected(); + if (current != enable) { + UIUtils.click(checkbox); + Assert.assertNotEquals("Checkbox " + checkbox + " is still in the state " + current + " after click.", current, checkbox.isSelected()); + } + }, maxAttempts, 0); + } + /** * This is as an alternative for {@link #clickLink(WebElement)} and should be used in situations where we can't use * {@link WaitUtils#waitForPageToLoad()}. This is because {@link WaitUtils#waitForPageToLoad()} would wait until the