Stabilize test testAccountManagementLinkIdentity by waiting for username to appear
Closes #15054
This commit is contained in:
parent
ec73533895
commit
9b80bad391
1 changed files with 15 additions and 16 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue