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 b72035aae1..3724ccd3b7 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 @@ -21,6 +21,7 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.junit.Assert; import org.keycloak.testsuite.util.DroneUtils; import org.keycloak.testsuite.util.OAuthClient; +import org.keycloak.testsuite.util.WaitUtils; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; @@ -46,9 +47,6 @@ public class LoginPage extends LanguageComboboxAwarePage { @FindBy(id = "input-error") private WebElement inputError; - @FindBy(id = "totp") - private WebElement totp; - @FindBy(id = "rememberMe") private WebElement rememberMe; @@ -64,15 +62,9 @@ public class LoginPage extends LanguageComboboxAwarePage { @FindBy(linkText = "Forgot Password?") private WebElement resetPasswordLink; - @FindBy(linkText = "Username") - private WebElement recoverUsernameLink; - @FindBy(className = "alert-error") private WebElement loginErrorMessage; - @FindBy(className = "alert-warning") - private WebElement loginWarningMessage; - @FindBy(className = "alert-success") private WebElement loginSuccessMessage; @@ -85,7 +77,7 @@ public class LoginPage extends LanguageComboboxAwarePage { public void login(String username, String password) { - usernameInput.clear(); + clearUsernameInputAndWaitIfNecessary(); usernameInput.sendKeys(username); passwordInput.clear(); @@ -94,6 +86,17 @@ public class LoginPage extends LanguageComboboxAwarePage { clickLink(submitButton); } + private void clearUsernameInputAndWaitIfNecessary() { + try { + usernameInput.clear(); + } catch (NoSuchElementException ex) { + // we might have clicked on a social login icon and might need to wait for the login to appear. + // avoid waiting by default to avoid the delay. + WaitUtils.waitUntilElement(usernameInput).is().present(); + usernameInput.clear(); + } + } + public void login(String password) { passwordInput.clear(); passwordInput.sendKeys(password); @@ -102,14 +105,14 @@ public class LoginPage extends LanguageComboboxAwarePage { } public void missingPassword(String username) { - usernameInput.clear(); + clearUsernameInputAndWaitIfNecessary(); usernameInput.sendKeys(username); passwordInput.clear(); clickLink(submitButton); } public void missingUsername() { - usernameInput.clear(); + clearUsernameInputAndWaitIfNecessary(); clickLink(submitButton); } @@ -212,10 +215,6 @@ public class LoginPage extends LanguageComboboxAwarePage { clickLink(resetPasswordLink); } - public void recoverUsername() { - clickLink(recoverUsernameLink); - } - public void setRememberMe(boolean enable) { boolean current = rememberMe.isSelected(); if (current != enable) {