Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
ClickElement replaces readyElement(element).click
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed May 15, 2015
1 parent e88ad1a commit dac9e33
Show file tree
Hide file tree
Showing 37 changed files with 82 additions and 91 deletions.
15 changes: 3 additions & 12 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -85,7 +85,7 @@ public BasePage(final WebDriver driver) {

public DashboardBasePage goToMyDashboard() {
log.info("Click Dashboard menu link");
readyElement(userAvatar).click();
clickElement(userAvatar);
clickLinkAfterAnimation(BY_DASHBOARD_LINK);
return new DashboardBasePage(getDriver());
}
Expand All @@ -103,16 +103,7 @@ private void clickNavMenuItem(final WebElement menuItem) {
// screen is too small the menu become dropdown
readyElement(existingElement(By.id("nav-main")), By.tagName("a")).click();
}
waitForAMoment().withMessage("displayed: " + menuItem).until(
new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return menuItem.isDisplayed();
}
});
waitForAMoment().withMessage("clickable: " + menuItem).until(
ExpectedConditions.elementToBeClickable(menuItem));
menuItem.click();
clickElement(menuItem);
}

public VersionGroupsPage goToGroups() {
Expand Down Expand Up @@ -318,7 +309,7 @@ public WebElement apply(WebDriver driver) {
return null;
}
});
searchItem.click();
clickElement(searchItem);
}

public void clickWhenTabEnabled(final WebElement tab) {
Expand Down
6 changes: 3 additions & 3 deletions functional-test/src/main/java/org/zanata/page/CorePage.java
Expand Up @@ -62,20 +62,20 @@ public String getTitle() {
public HomePage goToHomePage() {
log.info("Click Zanata home icon");
scrollToTop();
readyElement(homeLink).click();
clickElement(homeLink);
return new HomePage(getDriver());
}

protected void clickAndCheckErrors(WebElement button) {
button.click();
clickElement(button);
List<String> errors = getErrors();
if (!errors.isEmpty()) {
throw new RuntimeException(Joiner.on(";").join(errors));
}
}

protected void clickAndExpectErrors(WebElement button) {
button.click();
clickElement(button);
refreshPageUntil(this, new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
Expand Down
Expand Up @@ -68,13 +68,13 @@ public EditProfilePage enterEmail(String email) {

public HomePage clickSave() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new HomePage(getDriver());
}

public EditProfilePage clickSaveAndExpectErrors() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new EditProfilePage(getDriver());
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public InactiveAccountPage(WebDriver driver) {

public HomePage clickResendActivationEmail() {
log.info("Click resend activation email");
readyElement(By.id("resendEmail")).click();
clickElement(By.id("resendEmail"));
return new HomePage(getDriver());
}

Expand All @@ -49,7 +49,7 @@ public InactiveAccountPage enterNewEmail(String email) {
}

public HomePage clickUpdateEmail() {
readyElement(By.id("inactiveAccountForm:emailField:updateEmail")).click();
clickElement(By.id("inactiveAccountForm:emailField:updateEmail"));
return new HomePage(getDriver());
}
}
Expand Up @@ -89,13 +89,13 @@ public RegisterPage enterPassword(String password) {
// TODO: Add a "signup success" page
public HomePage register() {
log.info("Click Sign Up");
readyElement(signUpButton).click();
clickElement(signUpButton);
return new HomePage(getDriver());
}

public RegisterPage registerFailure() {
log.info("Click Sign Up");
readyElement(signUpButton).click();
clickElement(signUpButton);
return new RegisterPage(getDriver());
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public String getPageTitle() {

public SignInPage goToSignIn() {
log.info("Click Log In");
readyElement(loginLink).click();
clickElement(loginLink);
return new SignInPage(getDriver());
}

public RegisterPage clickPasswordShowToggle() {
log.info("Click Show/Hide");
readyElement(showHideToggleButton).click();
clickElement(showHideToggleButton);
return new RegisterPage(getDriver());
}

Expand Down
Expand Up @@ -59,15 +59,15 @@ public HomePage resetPassword() {
log.info("Click Submit");
defocus(usernameEmailField);
waitForPageSilence();
readyElement(submitButton).click();
clickElement(submitButton);
return new HomePage(getDriver());
}

public ResetPasswordPage resetFailure() {
log.info("Click Submit");
defocus(usernameEmailField);
waitForPageSilence();
readyElement(submitButton).click();
clickElement(submitButton);
return new ResetPasswordPage(getDriver());
}
}
Expand Up @@ -61,37 +61,37 @@ public SignInPage enterPassword(String password) {

public DashboardBasePage clickSignIn() {
log.info("Click Sign In");
readyElement(signInButton).click();
clickElement(signInButton);
return new DashboardBasePage(getDriver());
}

public SignInPage clickSignInExpectError() {
log.info("Click Sign In");
readyElement(signInButton).click();
clickElement(signInButton);
return new SignInPage(getDriver());
}

public InactiveAccountPage clickSignInExpectInactive() {
log.info("Click Sign In");
readyElement(signInButton).click();
clickElement(signInButton);
return new InactiveAccountPage(getDriver());
}

public GoogleAccountPage selectGoogleOpenID() {
log.info("Click 'Google'");
readyElement(googleButton).click();
clickElement(googleButton);
return new GoogleAccountPage(getDriver());
}

public ResetPasswordPage goToResetPassword() {
log.info("Click Forgot Password");
readyElement(forgotPasswordLink).click();
clickElement(forgotPasswordLink);
return new ResetPasswordPage(getDriver());
}

public RegisterPage goToRegister() {
log.info("Click Sign Up");
readyElement(signUpLink).click();
clickElement(signUpLink);
return new RegisterPage(getDriver());
}

Expand Down
Expand Up @@ -90,15 +90,15 @@ public AddLanguagePage expectPluralsWarning() {
public AddLanguagePage enableLanguageByDefault() {
log.info("Click Enable by default");
if (!readyElement(enabledByDefaultCheckbox).isSelected()) {
readyElement(enabledByDefaultCheckbox).click();
clickElement(enabledByDefaultCheckbox);
}
return new AddLanguagePage(getDriver());
}

public AddLanguagePage disableLanguageByDefault() {
log.info("Click Disable by default");
if (readyElement(enabledByDefaultCheckbox).isSelected()) {
readyElement(enabledByDefaultCheckbox).click();
clickElement(enabledByDefaultCheckbox);
}

return new AddLanguagePage(getDriver());
Expand Down
Expand Up @@ -49,13 +49,13 @@ public EditHomeCodePage enterText(String text) {

public HomePage update() {
log.info("Click Update");
readyElement(updateButton).click();
clickElement(updateButton);
return new HomePage(getDriver());
}

public HomePage cancelUpdate() {
log.info("Click Cancel");
readyElement(cancelButton).click();
clickElement(cancelButton);
return new HomePage(getDriver());
}
}
Expand Up @@ -54,13 +54,13 @@ public EditHomeContentPage enterText(String text) {

public HomePage update() {
log.info("Click Update");
readyElement(updateButton).click();
clickElement(updateButton);
return new HomePage(getDriver());
}

public HomePage cancelUpdate() {
log.info("Click Cancel");
readyElement(cancelButton).click();
clickElement(cancelButton);
return new HomePage(getDriver());
}
}
Expand Up @@ -63,13 +63,13 @@ public EditRoleAssignmentPage selectRole(String role) {

public RoleAssignmentsPage saveRoleAssignment() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new RoleAssignmentsPage(getDriver());
}

public RoleAssignmentsPage cancelEditRoleAssignment() {
log.info("Click Cancel");
readyElement(cancelButton).click();
clickElement(cancelButton);
return new RoleAssignmentsPage(getDriver());
}
}
Expand Up @@ -71,7 +71,7 @@ public ManageSearchPage selectAllActionsFor(String clazz) {

public ManageSearchPage clickSelectAll() {
log.info("Click Select All");
readyElement(selectAllButton).click();
clickElement(selectAllButton);
// It seems that if the Select All and Perform buttons are clicked too
// quickly in succession, the operation will fail
try {
Expand Down Expand Up @@ -101,7 +101,7 @@ public boolean allActionsSelected() {

public ManageSearchPage performSelectedActions() {
log.info("Click Perform Actions");
readyElement(performButton).click();
clickElement(performButton);
waitForAMoment().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
Expand All @@ -121,7 +121,7 @@ public ManageSearchPage expectActionsToFinish() {

public ManageSearchPage abort() {
log.info("Click Abort");
readyElement(abortButton).click();
clickElement(abortButton);
return new ManageSearchPage(getDriver());
}

Expand Down
Expand Up @@ -70,7 +70,7 @@ public ManageUserAccountPage enterConfirmPassword(String confirmPassword) {

public ManageUserAccountPage clickEnabled() {
log.info("Click Enabled");
readyElement(enabledField).click();
clickElement(enabledField);
return new ManageUserAccountPage(getDriver());
}

Expand All @@ -89,19 +89,19 @@ public boolean isRoleChecked(String role) {

public ManageUserPage saveUser() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new ManageUserPage(getDriver());
}

public ManageUserAccountPage saveUserExpectFailure() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new ManageUserAccountPage(getDriver());
}

public ManageUserPage cancelEditUser() {
log.info("Click Cancel");
readyElement(cancelButton).click();
clickElement(cancelButton);
return new ManageUserPage(getDriver());
}

Expand Down
Expand Up @@ -45,13 +45,13 @@ public RoleAssignmentsPage(WebDriver driver) {

public RoleAssignmentsPage clickMoreActions() {
log.info("Click More Actions dropdown");
readyElement(moreActions).click();
clickElement(moreActions);
return new RoleAssignmentsPage(getDriver());
}

public EditRoleAssignmentPage clickCreateNew() {
log.info("Click Create New");
readyElement(newRuleButton).click();
clickElement(newRuleButton);
return new EditRoleAssignmentPage(getDriver());
}

Expand Down
Expand Up @@ -191,7 +191,7 @@ public String getMaxActiveRequestsPerApiKey() {

public AdministrationPage save() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new AdministrationPage(getDriver());
}

Expand Down
Expand Up @@ -55,19 +55,19 @@ public TranslationMemoryEditPage enterMemoryDescription(String description) {

public TranslationMemoryPage saveTM() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new TranslationMemoryPage(getDriver());
}

public TranslationMemoryEditPage clickSaveAndExpectFailure() {
log.info("Click Save");
readyElement(saveButton).click();
clickElement(saveButton);
return new TranslationMemoryEditPage(getDriver());
}

public TranslationMemoryPage cancelTM() {
log.info("Click Cancel");
readyElement(cancelButton).click();
clickElement(cancelButton);
return new TranslationMemoryPage(getDriver());
}

Expand Down
Expand Up @@ -59,7 +59,7 @@ public TranslationMemoryPage(WebDriver driver) {

public TranslationMemoryEditPage clickCreateNew() {
log.info("Click Create New");
readyElement(dropDownMenu).click();
clickElement(dropDownMenu);
clickLinkAfterAnimation(createTmLink);
return new TranslationMemoryEditPage(getDriver());
}
Expand All @@ -84,14 +84,14 @@ public TranslationMemoryPage enterImportFileName(String importFileName) {

public TranslationMemoryPage clickUploadButtonAndAcknowledge() {
log.info("Click and accept Upload button");
readyElement(uploadButton).click();
clickElement(uploadButton);
switchToAlert().accept();
return new TranslationMemoryPage(getDriver());
}

public Alert expectFailedUpload() {
log.info("Click Upload");
readyElement(uploadButton).click();
clickElement(uploadButton);
return switchToAlert();
}

Expand Down
Expand Up @@ -53,7 +53,7 @@ public List<WebElement> getMyActivityList() {
public boolean clickMoreActivity() {
log.info("Click More Activity button");
final int activityListOrigSize = getMyActivityList().size();
readyElement(moreActivityButton).click();
clickElement(moreActivityButton);
return waitForAMoment().until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver input) {
Expand Down

0 comments on commit dac9e33

Please sign in to comment.