Refactoring of arquillian waiting methods.

This commit is contained in:
Tomas Kyjovsky 2015-12-02 15:58:23 +01:00
parent e44d6f9888
commit 46e2440d30
36 changed files with 128 additions and 157 deletions

View file

@ -5,7 +5,7 @@ import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl; import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl;
import org.keycloak.testsuite.util.WaitUtils; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
/** /**
@ -61,7 +61,7 @@ public class CustomerPortalExample extends AbstractPageWithInjectedUrl {
} }
public void customerSession() { public void customerSession() {
WaitUtils.waitGuiForElement(customerSessionLink); waitUntilElement(customerSessionLink).is().present();
customerSessionLink.click(); customerSessionLink.click();
} }
@ -70,11 +70,11 @@ public class CustomerPortalExample extends AbstractPageWithInjectedUrl {
} }
public void waitForCustomerListingHeader() { public void waitForCustomerListingHeader() {
WaitUtils.waitGuiForElementNotPresent(customerListingHeader); waitUntilElement(customerListingHeader).is().not().present();
} }
public void waitForCustomerSessionHeader() { public void waitForCustomerSessionHeader() {
WaitUtils.waitGuiForElementNotPresent(customerSessionHeader); waitUntilElement(customerSessionHeader).is().not().present();
} }
} }

View file

@ -5,7 +5,7 @@ import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl; import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl;
import org.keycloak.testsuite.util.WaitUtils; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
/** /**
@ -48,7 +48,7 @@ public class ProductPortalExample extends AbstractPageWithInjectedUrl {
} }
public void waitForProductListingHeader() { public void waitForProductListingHeader() {
WaitUtils.waitGuiForElementNotPresent(productListingHeader); waitUntilElement(productListingHeader).is().not().present();
} }
public void logOut() { public void logOut() {

View file

@ -2,8 +2,7 @@ package org.keycloak.testsuite.auth.page.account;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElementNotPresent;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -49,11 +48,11 @@ public class AccountFields extends Form {
} }
public void waitForUsernameInputPresent() { public void waitForUsernameInputPresent() {
waitAjaxForElement(usernameInput); waitUntilElement(usernameInput).is().present();
} }
public void waitForUsernameInputNotPresent() { public void waitForUsernameInputNotPresent() {
waitAjaxForElementNotPresent(usernameInput); waitUntilElement(usernameInput).is().not().present();
} }
} }

View file

@ -21,7 +21,7 @@ import javax.ws.rs.core.UriBuilder;
import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.testsuite.auth.page.AuthRealm; import org.keycloak.testsuite.auth.page.AuthRealm;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElementPresent; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -66,10 +66,10 @@ public class AccountManagement extends AuthRealm {
private WebElement error; private WebElement error;
public String getErrorMessage() { public String getErrorMessage() {
waitGuiForElementPresent(error, "Error message should be visible"); waitUntilElement(error, "Error message should be present").is().present();
return error.getText(); return error.getText();
} }
public void backToReferer() { public void backToReferer() {
backToRefererLink.click(); backToRefererLink.click();
} }
@ -101,12 +101,12 @@ public class AccountManagement extends AuthRealm {
public void save() { public void save() {
save.click(); save.click();
} }
public RealmResource realmResource() { public RealmResource realmResource() {
return keycloak().realm(getAuthRealm()); return keycloak().realm(getAuthRealm());
} }
public void waitForAccountLinkPresent() { public void waitForAccountLinkPresent() {
waitGuiForElementPresent(accountLink, "account link should be present"); waitUntilElement(accountLink, "account link should be present").is().present();
} }
} }

View file

@ -18,7 +18,7 @@
package org.keycloak.testsuite.auth.page.account; package org.keycloak.testsuite.auth.page.account;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import org.keycloak.testsuite.util.WaitUtils; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -54,6 +54,6 @@ public class PasswordFields extends Form {
} }
public void waitForConfirmPasswordInputPresent() { public void waitForConfirmPasswordInputPresent() {
WaitUtils.waitGuiForElement(confirmPasswordInput); waitUntilElement(confirmPasswordInput).is().present();
} }
} }

View file

@ -20,8 +20,7 @@ package org.keycloak.testsuite.auth.page.login;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.auth.page.AuthRealm; import org.keycloak.testsuite.auth.page.AuthRealm;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElementNotPresent;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -62,11 +61,11 @@ public abstract class Login extends AuthRealm {
private WebElement keycloakTheme; private WebElement keycloakTheme;
public void waitForKeycloakThemeNotPresent() { public void waitForKeycloakThemeNotPresent() {
waitGuiForElementNotPresent(keycloakTheme); waitUntilElement(keycloakTheme).is().not().present();
} }
public void waitForKeycloakThemePresent() { public void waitForKeycloakThemePresent() {
waitGuiForElement(keycloakTheme); waitUntilElement(keycloakTheme).is().present();
} }
} }

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.auth.page.login;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import org.keycloak.testsuite.auth.page.AuthRealm; import org.keycloak.testsuite.auth.page.AuthRealm;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElementPresent; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -45,7 +45,7 @@ public class LoginActions extends AuthRealm {
private WebElement feedbackText; private WebElement feedbackText;
public String getFeedbackText() { public String getFeedbackText() {
waitGuiForElementPresent(feedbackText, "Feedback message should be visible"); waitUntilElement(feedbackText, "Feedback message should be present").is().present();
return feedbackText.getText(); return feedbackText.getText();
} }

View file

@ -70,20 +70,20 @@ public class LoginForm extends Form {
public void register() { public void register() {
waitForUsernameInputPresent(); waitForUsernameInputPresent();
waitAjaxForElement(registerLink); waitUntilElement(registerLink).is().present();
registerLink.click(); registerLink.click();
} }
public void login() { public void login() {
waitAjaxForElement(loginButton); waitUntilElement(loginButton).is().present();
loginButton.click(); loginButton.click();
} }
public void forgotPassword() { public void forgotPassword() {
waitAjaxForElement(forgottenPassword); waitUntilElement(forgottenPassword).is().present();
forgottenPassword.click(); forgottenPassword.click();
} }
public void rememberMe(boolean value) { public void rememberMe(boolean value) {
waitForRememberMePresent(); waitForRememberMePresent();
boolean selected = rememberMe.isSelected(); boolean selected = rememberMe.isSelected();
@ -94,32 +94,31 @@ public class LoginForm extends Form {
// @Override // @Override
// public void cancel() { // public void cancel() {
// waitAjaxForElement(cancelButton); // waitUntilElement(cancelButton).is().present();
// cancelButton.click(); // cancelButton.click();
// } // }
public void waitForUsernameInputPresent() { public void waitForUsernameInputPresent() {
accountFields.waitForUsernameInputPresent(); accountFields.waitForUsernameInputPresent();
} }
public void waitForRegisterLinkNotPresent() { public void waitForRegisterLinkNotPresent() {
waitAjaxForElementNotPresent(registerLink); waitUntilElement(registerLink).is().not().present();
} }
public void waitForResetPasswordLinkNotPresent() { public void waitForResetPasswordLinkNotPresent() {
waitAjaxForElementNotPresent(forgottenPassword); waitUntilElement(forgottenPassword).is().not().present();
} }
public void waitForRememberMePresent() { public void waitForRememberMePresent() {
waitAjaxForElement(rememberMe); waitUntilElement(rememberMe).is().present();
} }
public void waitForRememberMeNotPresent() { public void waitForRememberMeNotPresent() {
waitAjaxForElementNotPresent(rememberMe); waitUntilElement(rememberMe).is().not().present();
} }
public void waitForLoginButtonPresent() { public void waitForLoginButtonPresent() {
waitGuiForElement(loginButton); waitUntilElement(loginButton).is().present();
} }
} }

View file

@ -21,7 +21,7 @@ import javax.ws.rs.core.UriBuilder;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.auth.page.account.AccountFields; import org.keycloak.testsuite.auth.page.account.AccountFields;
import org.keycloak.testsuite.auth.page.account.PasswordFields; import org.keycloak.testsuite.auth.page.account.PasswordFields;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElementPresent; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -57,7 +57,7 @@ public class ResetCredentials extends LoginActions {
} }
public String getInfoMessage() { public String getInfoMessage() {
waitGuiForElementPresent(info, "Info message should be visible"); waitUntilElement(info, "Info message should be visible").is().present();
return info.getText(); return info.getText();
} }
} }

View file

@ -21,7 +21,7 @@
*/ */
package org.keycloak.testsuite.auth.page.login; package org.keycloak.testsuite.auth.page.login;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -35,7 +35,7 @@ public class VerifyEmail extends Authenticate {
private WebElement instruction; private WebElement instruction;
public String getInstructionMessage() { public String getInstructionMessage() {
waitGuiForElement(instruction); waitUntilElement(instruction).is().present();
return instruction.getText(); return instruction.getText();
} }
} }

View file

@ -3,8 +3,7 @@ package org.keycloak.testsuite.console.page;
import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RealmResource;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST; import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
import org.keycloak.testsuite.util.WaitUtils; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -39,7 +38,7 @@ public class AdminConsoleRealm extends AdminConsoleRealmsRoot {
private ConfigureMenu configureMenu; private ConfigureMenu configureMenu;
public ConfigureMenu configure() { public ConfigureMenu configure() {
waitGuiForElement(By.xpath("//div[./h2[text()='Configure']]")); waitUntilElement(By.xpath("//div[./h2[text()='Configure']]")).is().present();
return configureMenu; return configureMenu;
} }
@ -92,7 +91,7 @@ public class AdminConsoleRealm extends AdminConsoleRealmsRoot {
protected ManageMenu manageMenu; protected ManageMenu manageMenu;
public ManageMenu manage() { public ManageMenu manage() {
WaitUtils.waitGuiForElement(By.xpath("//div[./h2[text()='Manage']]")); waitUntilElement(By.xpath("//div[./h2[text()='Manage']]")).is().present();
return manageMenu; return manageMenu;
} }

View file

@ -24,12 +24,12 @@ public class Authentication extends AdminConsoleRealm {
private WebElement close; private WebElement close;
public String getSuccessMessage() { public String getSuccessMessage() {
waitAjaxForElement(success); waitUntilElement(success).is().present();
return success.getText(); return success.getText();
} }
public String getErrorMessage() { public String getErrorMessage() {
waitAjaxForElement(error); waitUntilElement(error).is().present();
return error.getText(); return error.getText();
} }
@ -37,7 +37,7 @@ public class Authentication extends AdminConsoleRealm {
if (close.isDisplayed()) { if (close.isDisplayed()) {
close.click(); close.click();
} }
waitAjaxForElementNotVisible(close); waitUntilElement(close).is().not().visible();
} }
public AuthenticationTabs tabs() { public AuthenticationTabs tabs() {

View file

@ -8,7 +8,7 @@ import org.openqa.selenium.support.ui.Select;
import java.util.List; import java.util.List;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
/** /**
* @author Petr Mensik * @author Petr Mensik
@ -32,7 +32,7 @@ public class PasswordPolicy extends Authentication {
private List<WebElement> allRows; private List<WebElement> allRows;
public void addPolicy(PasswordPolicy.Type policy, String value) { public void addPolicy(PasswordPolicy.Type policy, String value) {
waitGuiForElement(addPolicySelectElement); waitUntilElement(addPolicySelectElement).is().present();
addPolicySelect.selectByVisibleText(policy.getName()); addPolicySelect.selectByVisibleText(policy.getName());
setPolicyValue(policy, value); setPolicyValue(policy, value);
primaryButton.click(); primaryButton.click();

View file

@ -21,7 +21,7 @@
*/ */
package org.keycloak.testsuite.console.page.authentication.flows; package org.keycloak.testsuite.console.page.authentication.flows;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -71,7 +71,7 @@ public class FlowsTable {
private WebElement getRowByLabelText(String text) { private WebElement getRowByLabelText(String text) {
WebElement row = tbody.findElement(By.xpath("//span[text() = '" + text + "']/../..")); WebElement row = tbody.findElement(By.xpath("//span[text() = '" + text + "']/../.."));
waitAjaxForElement(row); waitUntilElement(row).is().present();
return row; return row;
} }

View file

@ -38,17 +38,17 @@ public class ClientMappers extends Client {
} }
public void createMapper() { public void createMapper() {
waitAjaxForBody(); waitForBody();
clickHeaderLink(CREATE); clickHeaderLink(CREATE);
} }
public void addBuiltin() { public void addBuiltin() {
waitAjaxForBody(); waitForBody();
clickHeaderLink(ADD_BUILTIN); clickHeaderLink(ADD_BUILTIN);
} }
public void clickMapper(String mapperName) { public void clickMapper(String mapperName) {
waitAjaxForBody(); waitForBody();
body().findElement(By.linkText(mapperName)).click(); body().findElement(By.linkText(mapperName)).click();
} }
@ -57,7 +57,7 @@ public class ClientMappers extends Client {
} }
private void clickMapperActionButton(String mapperName, String buttonText) { private void clickMapperActionButton(String mapperName, String buttonText) {
waitAjaxForBody(); waitForBody();
clickRowActionButton(getRowByLinkText(mapperName), buttonText); clickRowActionButton(getRowByLinkText(mapperName), buttonText);
} }

View file

@ -62,32 +62,32 @@ public class Clients extends AdminConsoleRealm {
} }
public void createClient() { public void createClient() {
waitAjaxForBody(); waitForBody();
clickHeaderLink(CREATE); clickHeaderLink(CREATE);
} }
public void importClient() { public void importClient() {
waitAjaxForBody(); waitForBody();
clickHeaderLink(IMPORT); clickHeaderLink(IMPORT);
} }
public void clickClient(ClientRepresentation client) { public void clickClient(ClientRepresentation client) {
waitAjaxForBody(); waitForBody();
clickClient(client.getClientId()); clickClient(client.getClientId());
} }
public void clickClient(String clientId) { public void clickClient(String clientId) {
waitAjaxForBody(); waitForBody();
body().findElement(linkText(clientId)).click(); body().findElement(linkText(clientId)).click();
} }
public void editClient(String clientId) { public void editClient(String clientId) {
waitAjaxForBody(); waitForBody();
clickRowActionButton(getRowByLinkText(clientId), EDIT); clickRowActionButton(getRowByLinkText(clientId), EDIT);
} }
public void deleteClient(String clientId) { public void deleteClient(String clientId) {
waitAjaxForBody(); waitForBody();
clickRowActionButton(getRowByLinkText(clientId), DELETE); clickRowActionButton(getRowByLinkText(clientId), DELETE);
} }

View file

@ -8,7 +8,7 @@ import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import static org.keycloak.testsuite.page.Form.getInputValue; import static org.keycloak.testsuite.page.Form.getInputValue;
import static org.keycloak.testsuite.util.WaitUtils.pause; import static org.keycloak.testsuite.util.WaitUtils.pause;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.keycloak.testsuite.util.Timer; import org.keycloak.testsuite.util.Timer;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -69,7 +69,7 @@ public class CreateClientForm extends Form {
private List<WebElement> deleteRedirectUriIcons; private List<WebElement> deleteRedirectUriIcons;
public void setValues(ClientRepresentation client) { public void setValues(ClientRepresentation client) {
waitAjaxForElement(clientIdInput); waitUntilElement(clientIdInput).is().present();
setClientId(client.getClientId()); setClientId(client.getClientId());
setName(client.getName()); setName(client.getName());
@ -230,7 +230,7 @@ public class CreateClientForm extends Form {
} }
public String getProtocol() { public String getProtocol() {
waitAjaxForElement(protocolSelect.getFirstSelectedOption()); waitUntilElement(protocolSelect.getFirstSelectedOption()).is().present();
return protocolSelect.getFirstSelectedOption().getText(); return protocolSelect.getFirstSelectedOption().getText();
} }

View file

@ -33,17 +33,17 @@ public class AdminEvents extends Events {
private AdminEventsTableFilterForm filterForm; private AdminEventsTableFilterForm filterForm;
public void update() { public void update() {
waitAjaxForBody(); waitForBody();
clickHeaderButton("Update"); clickHeaderButton("Update");
} }
public void reset() { public void reset() {
waitAjaxForBody(); waitForBody();
clickHeaderButton("Reset"); clickHeaderButton("Reset");
} }
public void filter() { public void filter() {
waitAjaxForBody(); waitForBody();
filterButton.click(); filterButton.click();
} }

View file

@ -104,7 +104,7 @@ public class Config extends Events {
} }
public void waitForClearEventsButtonPresent() { public void waitForClearEventsButtonPresent() {
waitAjaxForElement(clearLoginEventsButton); waitUntilElement(clearLoginEventsButton).is().present();
} }
} }
} }

View file

@ -33,17 +33,17 @@ public class LoginEvents extends Events {
private LoginEventsTableFilterForm filterForm; private LoginEventsTableFilterForm filterForm;
public void update() { public void update() {
waitAjaxForBody(); waitForBody();
clickHeaderButton("Update"); clickHeaderButton("Update");
} }
public void reset() { public void reset() {
waitAjaxForBody(); waitForBody();
clickHeaderButton("Reset"); clickHeaderButton("Reset");
} }
public void filter() { public void filter() {
waitAjaxForBody(); waitForBody();
filterButton.click(); filterButton.click();
} }

View file

@ -1,6 +1,6 @@
package org.keycloak.testsuite.console.page.federation; package org.keycloak.testsuite.console.page.federation;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
@ -50,7 +50,7 @@ public class KerberosUserProviderForm extends Form {
} }
public void setKerberosRealmInput(String kerberosRealm) { public void setKerberosRealmInput(String kerberosRealm) {
waitGuiForElement(By.id("kerberosRealm")); waitUntilElement(By.id("kerberosRealm")).is().present();
setInputValue(kerberosRealmInput, kerberosRealm); setInputValue(kerberosRealmInput, kerberosRealm);
} }
@ -71,7 +71,7 @@ public class KerberosUserProviderForm extends Form {
} }
public void selectEditMode(String mode) { public void selectEditMode(String mode) {
waitGuiForElement(By.id("editMode")); waitUntilElement(By.id("editMode")).is().present();
editModeSelect.selectByVisibleText(mode); editModeSelect.selectByVisibleText(mode);
} }

View file

@ -1,7 +1,7 @@
package org.keycloak.testsuite.console.page.federation; package org.keycloak.testsuite.console.page.federation;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
@ -156,17 +156,14 @@ public class LdapUserProviderForm extends Form {
} }
public void setKerberosRealmInput(String kerberosRealm) { public void setKerberosRealmInput(String kerberosRealm) {
waitAjaxForElement(kerberosRealmInput);
setInputValue(kerberosRealmInput, kerberosRealm); setInputValue(kerberosRealmInput, kerberosRealm);
} }
public void setServerPrincipalInput(String serverPrincipal) { public void setServerPrincipalInput(String serverPrincipal) {
waitAjaxForElement(serverPrincipalInput);
setInputValue(serverPrincipalInput, serverPrincipal); setInputValue(serverPrincipalInput, serverPrincipal);
} }
public void setKeyTabInput(String keyTab) { public void setKeyTabInput(String keyTab) {
waitAjaxForElement(keyTabInput);
setInputValue(keyTabInput, keyTab); setInputValue(keyTabInput, keyTab);
} }
@ -175,22 +172,22 @@ public class LdapUserProviderForm extends Form {
} }
public void selectEditMode(String mode) { public void selectEditMode(String mode) {
waitGuiForElement(By.id("editMode")); waitUntilElement(By.id("editMode")).is().present();
editModeSelect.selectByVisibleText(mode); editModeSelect.selectByVisibleText(mode);
} }
public void selectVendor(String vendor) { public void selectVendor(String vendor) {
waitGuiForElement(By.id("vendor")); waitUntilElement(By.id("vendor")).is().present();
vendorSelect.selectByVisibleText(vendor); vendorSelect.selectByVisibleText(vendor);
} }
public void selectAuthenticationType(String authenticationType) { public void selectAuthenticationType(String authenticationType) {
waitGuiForElement(By.id("authType")); waitUntilElement(By.id("authType")).is().present();
authTypeSelect.selectByVisibleText(authenticationType); authTypeSelect.selectByVisibleText(authenticationType);
} }
public void selectSearchScope(String searchScope) { public void selectSearchScope(String searchScope) {
waitGuiForElement(By.id("searchScope")); waitUntilElement(By.id("searchScope")).is().present();
searchScopeSelect.selectByVisibleText(searchScope); searchScopeSelect.selectByVisibleText(searchScope);
} }
@ -248,7 +245,7 @@ public class LdapUserProviderForm extends Form {
} }
public void synchronizeAllUsers() { public void synchronizeAllUsers() {
waitAjaxForElement(synchronizeAllUsersButton); waitUntilElement(synchronizeAllUsersButton).is().present();
synchronizeAllUsersButton.click(); synchronizeAllUsersButton.click();
} }
} }

View file

@ -5,7 +5,7 @@ import org.keycloak.testsuite.console.page.AdminConsoleRealm;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
/** /**
* Created by fkiss. * Created by fkiss.
@ -21,7 +21,7 @@ public class UserFederation extends AdminConsoleRealm {
private Select addProviderSelect; private Select addProviderSelect;
public void addProvider(String provider) { public void addProvider(String provider) {
waitGuiForElement(By.cssSelector("select[ng-model*='selectedProvider']")); waitUntilElement(By.cssSelector("select[ng-model*='selectedProvider']")).is().present();
addProviderSelect.selectByVisibleText(provider); addProviderSelect.selectByVisibleText(provider);
} }

View file

@ -2,7 +2,7 @@ package org.keycloak.testsuite.console.page.fragment;
import java.util.List; import java.util.List;
import static org.keycloak.testsuite.util.WaitUtils.pause; import static org.keycloak.testsuite.util.WaitUtils.pause;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import static org.openqa.selenium.By.xpath; import static org.openqa.selenium.By.xpath;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -30,18 +30,18 @@ public class DataTable {
private WebElement infoRow; private WebElement infoRow;
public void search(String pattern) { public void search(String pattern) {
waitAjaxForBody(); waitForBody();
searchInput.sendKeys(pattern); searchInput.sendKeys(pattern);
searchButton.click(); searchButton.click();
} }
public void clickHeaderButton(String buttonText) { public void clickHeaderButton(String buttonText) {
waitAjaxForBody(); waitForBody();
header.findElement(By.xpath(".//button[text()='" + buttonText + "']")).click(); header.findElement(By.xpath(".//button[text()='" + buttonText + "']")).click();
} }
public void clickHeaderLink(String linkText) { public void clickHeaderLink(String linkText) {
waitAjaxForBody(); waitForBody();
header.findElement(By.linkText(linkText)).click(); header.findElement(By.linkText(linkText)).click();
} }
@ -49,19 +49,19 @@ public class DataTable {
return body; return body;
} }
public void waitAjaxForBody() { public void waitForBody() {
waitAjaxForElement(body); waitUntilElement(body).is().present();
} }
public List<WebElement> rows() { public List<WebElement> rows() {
waitAjaxForBody(); waitForBody();
pause(250); pause(250);
return rows; return rows;
} }
public WebElement getRowByLinkText(String text) { public WebElement getRowByLinkText(String text) {
WebElement row = body.findElement(By.xpath(".//tr[./td/a[text()='" + text + "']]")); WebElement row = body.findElement(By.xpath(".//tr[./td/a[text()='" + text + "']]"));
waitAjaxForElement(row); waitUntilElement(row).is().present();
return row; return row;
} }

View file

@ -18,7 +18,7 @@
package org.keycloak.testsuite.console.page.fragment; package org.keycloak.testsuite.console.page.fragment;
import java.util.List; import java.util.List;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -53,7 +53,7 @@ public class Menu {
} }
public String getCurrentRealm() { public String getCurrentRealm() {
waitGuiForElement(By.cssSelector(MENU_LOCATOR)); waitUntilElement(By.cssSelector(MENU_LOCATOR)).is().present();
return toggle.get(1).getText(); return toggle.get(1).getText();
} }
@ -67,7 +67,7 @@ public class Menu {
menuOrder = 0; menuOrder = 0;
break; break;
} }
waitGuiForElement(By.cssSelector(MENU_LOCATOR)); waitUntilElement(By.cssSelector(MENU_LOCATOR)).is().present();
if (!menuList.get(menuOrder).isDisplayed()) { if (!menuList.get(menuOrder).isDisplayed()) {
toggle.get(menuOrder).click(); toggle.get(menuOrder).click();
} }

View file

@ -1,6 +1,6 @@
package org.keycloak.testsuite.console.page.fragment; package org.keycloak.testsuite.console.page.fragment;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -21,22 +21,22 @@ public class ModalDialog {
private WebElement nameInput; private WebElement nameInput;
public void ok() { public void ok() {
waitAjaxForElement(okButton); waitUntilElement(okButton).is().present();
okButton.click(); okButton.click();
} }
public void confirmDeletion() { public void confirmDeletion() {
waitAjaxForElement(deleteButton); waitUntilElement(deleteButton).is().present();
deleteButton.click(); deleteButton.click();
} }
public void cancel() { public void cancel() {
waitAjaxForElement(cancelButton); waitUntilElement(cancelButton).is().present();
cancelButton.click(); cancelButton.click();
} }
public void setName(String name) { public void setName(String name) {
waitAjaxForElement(nameInput); waitUntilElement(nameInput).is().present();
nameInput.clear(); nameInput.clear();
nameInput.sendKeys(name); nameInput.sendKeys(name);
} }

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.console.page.fragment;
import org.jboss.arquillian.graphene.fragment.Root; import org.jboss.arquillian.graphene.fragment.Root;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;
@ -45,12 +45,12 @@ public class OnOffSwitch {
} }
public boolean isOn() { public boolean isOn() {
waitAjaxForElement(root); waitUntilElement(root).is().present();
return root.findElement(By.tagName("input")).isSelected(); return root.findElement(By.tagName("input")).isSelected();
} }
private void click() { private void click() {
waitAjaxForElement(root); waitUntilElement(root).is().present();
actions.moveToElement(root.findElements(By.tagName("span")).get(0)) actions.moveToElement(root.findElements(By.tagName("span")).get(0))
.click().build().perform(); .click().build().perform();
} }

View file

@ -20,7 +20,7 @@ package org.keycloak.testsuite.console.page.realm;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
/** /**
@ -47,7 +47,7 @@ public class ThemeSettings extends RealmSettings {
private Select emailThemeSelect; private Select emailThemeSelect;
public void changeLoginTheme(String themeName) { public void changeLoginTheme(String themeName) {
waitGuiForElement(By.id("loginTheme")); waitUntilElement(By.id("loginTheme")).is().present();
loginThemeSelect.selectByVisibleText(themeName); loginThemeSelect.selectByVisibleText(themeName);
} }

View file

@ -23,7 +23,7 @@ import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;
import static java.lang.String.valueOf; import static java.lang.String.valueOf;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.apache.commons.lang3.text.WordUtils.capitalize; import static org.apache.commons.lang3.text.WordUtils.capitalize;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
@ -70,7 +70,7 @@ public class TokenSettings extends RealmSettings {
private void setTimeout(Select timeoutElement, WebElement unitElement, private void setTimeout(Select timeoutElement, WebElement unitElement,
int timeout, TimeUnit unit) { int timeout, TimeUnit unit) {
waitGuiForElement(sessionTimeout); waitUntilElement(sessionTimeout).is().present();
timeoutElement.selectByValue(capitalize(unit.name().toLowerCase())); timeoutElement.selectByValue(capitalize(unit.name().toLowerCase()));
unitElement.clear(); unitElement.clear();
unitElement.sendKeys(valueOf(timeout)); unitElement.sendKeys(valueOf(timeout));

View file

@ -9,7 +9,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.keycloak.representations.idm.RoleRepresentation.Composites; import org.keycloak.representations.idm.RoleRepresentation.Composites;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -127,7 +127,7 @@ public class RoleCompositeRoles extends Form {
// *** original methods *** // *** original methods ***
public void addAvailableRole(String... roles) { public void addAvailableRole(String... roles) {
waitGuiForElement(By.id("available")); waitUntilElement(By.id("available")).is().present();
for (String role : roles) { for (String role : roles) {
availableRealmRolesSelect.selectByVisibleText(role); availableRealmRolesSelect.selectByVisibleText(role);
addSelectedRealmRolesButton.click(); addSelectedRealmRolesButton.click();
@ -135,13 +135,13 @@ public class RoleCompositeRoles extends Form {
} }
public void removeAssignedRole(String role) { public void removeAssignedRole(String role) {
waitGuiForElement(By.id("assigned")); waitUntilElement(By.id("assigned")).is().present();
assignedRealmRolesSelect.selectByVisibleText(role); assignedRealmRolesSelect.selectByVisibleText(role);
removeSelectedRealmRolesButton.click(); removeSelectedRealmRolesButton.click();
} }
public boolean isAssignedRole(String role) { public boolean isAssignedRole(String role) {
waitGuiForElement(By.id("assigned")); waitUntilElement(By.id("assigned")).is().present();
try { try {
assignedRealmRolesSelect.selectByVisibleText(role); assignedRealmRolesSelect.selectByVisibleText(role);
} catch (Exception ex) { } catch (Exception ex) {
@ -151,7 +151,7 @@ public class RoleCompositeRoles extends Form {
} }
public boolean isAssignedClientRole(String role) { public boolean isAssignedClientRole(String role) {
waitGuiForElement(By.id("assigned")); waitUntilElement(By.id("assigned")).is().present();
try { try {
assignedClientRolesSelect.selectByVisibleText(role); assignedClientRolesSelect.selectByVisibleText(role);
} catch (Exception ex) { } catch (Exception ex) {
@ -161,12 +161,12 @@ public class RoleCompositeRoles extends Form {
} }
public void selectClientRole(String client) { public void selectClientRole(String client) {
waitGuiForElement(By.id("clients")); waitUntilElement(By.id("clients")).is().present();
clientSelect.selectByVisibleText(client); clientSelect.selectByVisibleText(client);
} }
public void addAvailableClientRole(String... roles) { public void addAvailableClientRole(String... roles) {
waitGuiForElement(By.id("available-client")); waitUntilElement(By.id("available-client")).is().present();
for (String role : roles) { for (String role : roles) {
availableClientRolesSelect.selectByVisibleText(role); availableClientRolesSelect.selectByVisibleText(role);
addSelectedClientRolesButton.click(); addSelectedClientRolesButton.click();
@ -174,7 +174,7 @@ public class RoleCompositeRoles extends Form {
} }
public void removeAssignedClientRole(String client) { public void removeAssignedClientRole(String client) {
waitGuiForElement(By.id("assigned-client")); waitUntilElement(By.id("assigned-client")).is().present();
assignedClientRolesSelect.selectByVisibleText(client); assignedClientRolesSelect.selectByVisibleText(client);
removeSelectedClientRolesButton.click(); removeSelectedClientRolesButton.click();
} }

View file

@ -28,7 +28,7 @@ public class RolesTable extends DataTable {
} }
public void clickRole(String name) { public void clickRole(String name) {
waitAjaxForBody(); waitForBody();
clickRowByLinkText(name); clickRowByLinkText(name);
} }

View file

@ -4,7 +4,7 @@ import java.util.List;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;
@ -125,7 +125,7 @@ public class UserAttributesForm extends Form {
} }
public void setValues(UserRepresentation user) { public void setValues(UserRepresentation user) {
waitAjaxForElement(usernameInput); waitUntilElement(usernameInput).is().present();
setUsername(user.getUsername()); setUsername(user.getUsername());
setEmail(user.getEmail()); setEmail(user.getEmail());
setFirstName(user.getFirstName()); setFirstName(user.getFirstName());

View file

@ -27,7 +27,7 @@ import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.console.page.AdminConsoleRealm; import org.keycloak.testsuite.console.page.AdminConsoleRealm;
import org.keycloak.testsuite.console.page.fragment.DataTable; import org.keycloak.testsuite.console.page.fragment.DataTable;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import static org.openqa.selenium.By.*; import static org.openqa.selenium.By.*;
/** /**
@ -73,7 +73,7 @@ public class Users extends AdminConsoleRealm {
} }
public void clickUser(String username) { public void clickUser(String username) {
waitAjaxForElement(body()); waitUntilElement(body()).is().present();
body().findElement(linkText(username)).click(); body().findElement(linkText(username)).click();
} }

View file

@ -4,7 +4,7 @@ import com.google.common.base.Predicate;
import static org.jboss.arquillian.graphene.Graphene.waitModel; import static org.jboss.arquillian.graphene.Graphene.waitModel;
import org.jboss.arquillian.graphene.fragment.Root; import org.jboss.arquillian.graphene.fragment.Root;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElementPresent; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -20,7 +20,7 @@ public abstract class AbstractAlert {
protected WebElement root; protected WebElement root;
public void waitUntilPresent() { public void waitUntilPresent() {
waitGuiForElementPresent(root, "Flash message should be visible."); waitUntilElement(root, "Flash message should be present.").is().present();
} }
public void waitUntilPresentAndClassSet() { public void waitUntilPresentAndClassSet() {

View file

@ -3,7 +3,7 @@ package org.keycloak.testsuite.page;
import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.drone.api.annotation.Drone;
import static org.jboss.arquillian.graphene.Graphene.guardAjax; import static org.jboss.arquillian.graphene.Graphene.guardAjax;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -36,14 +36,14 @@ public class Form {
} }
public static String getInputValue(WebElement input) { public static String getInputValue(WebElement input) {
waitAjaxForElement(input); waitUntilElement(input).is().present();
return input.getAttribute(VALUE); return input.getAttribute(VALUE);
} }
public static final String VALUE = "value"; public static final String VALUE = "value";
public static void setInputValue(WebElement input, String value) { public static void setInputValue(WebElement input, String value) {
waitAjaxForElement(input); waitUntilElement(input).is().present();
if (input.isEnabled()) { if (input.isEnabled()) {
input.clear(); input.clear();
if (value != null) { if (value != null) {

View file

@ -19,8 +19,8 @@ package org.keycloak.testsuite.util;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static org.jboss.arquillian.graphene.Graphene.waitAjax;
import static org.jboss.arquillian.graphene.Graphene.waitGui; import static org.jboss.arquillian.graphene.Graphene.waitGui;
import org.jboss.arquillian.graphene.wait.ElementBuilder;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -35,38 +35,16 @@ public final class WaitUtils {
public static final Integer PAGELOAD_TIMEOUT = Integer.parseInt(System.getProperty(PAGELOAD_TIMEOUT_PROP, "60000")); public static final Integer PAGELOAD_TIMEOUT = Integer.parseInt(System.getProperty(PAGELOAD_TIMEOUT_PROP, "60000"));
public static void waitAjaxForElement(WebElement element) { public static ElementBuilder<Void> waitUntilElement(By by) {
waitAjax() return waitGui().until().element(by);
.until().element(element).is().present();
} }
public static void waitAjaxForElementNotPresent(WebElement element) { public static ElementBuilder<Void> waitUntilElement(WebElement element) {
waitAjax() return waitGui().until().element(element);
.until().element(element).is().not().present();
} }
public static void waitAjaxForElementNotVisible(WebElement element) { public static ElementBuilder<Void> waitUntilElement(WebElement element, String failMessage) {
waitAjax() return waitGui().until(failMessage).element(element);
.until().element(element).is().not().visible();
}
public static void waitGuiForElement(By element) {
waitGui()
.until().element(element).is().present();
}
public static void waitGuiForElement(WebElement element) {
waitGuiForElementPresent(element, null);
}
public static void waitGuiForElementPresent(WebElement element, String message) {
waitGui()
.until(message).element(element).is().present();
}
public static void waitGuiForElementNotPresent(WebElement element) {
waitGui()
.until().element(element).is().not().present();
} }
public static void pause(long millis) { public static void pause(long millis) {