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
This forces all clicks to move the element into focus and wait for
obstructions to be gone before proceeding.
  • Loading branch information
djansen-redhat committed Jun 1, 2015
1 parent 9cbb810 commit 751aba2
Show file tree
Hide file tree
Showing 38 changed files with 93 additions and 100 deletions.
17 changes: 4 additions & 13 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 @@ -101,18 +101,9 @@ private void clickNavMenuItem(final WebElement menuItem) {
slightPause();
if (!menuItem.isDisplayed()) {
// screen is too small the menu become dropdown
readyElement(existingElement(By.id("nav-main")), By.tagName("a")).click();
clickElement(readyElement(existingElement(By.id("nav-main")), By.tagName("a")));
}
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 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,14 +70,14 @@ public ManageUserAccountPage enterConfirmPassword(String confirmPassword) {

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

public ManageUserAccountPage clickRole(String role) {
log.info("Click role {}", role);
readyElement(By.id("userdetailForm:rolesField:roles:"
.concat(roleMap.get(role)))).click();
clickElement(readyElement(By.id("userdetailForm:rolesField:roles:"
.concat(roleMap.get(role)))));
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 @@ -44,7 +44,7 @@ public ManageUserPage(WebDriver driver) {

public ManageUserAccountPage editUserAccount(String username) {
log.info("Click edit on {}", username);
findRowByUserName(username).click();
clickElement(findRowByUserName(username));
return new ManageUserAccountPage(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 @@ -58,6 +58,7 @@ public ServerConfigurationPage(WebDriver driver) {

private void enterTextConfigField(By by, String text) {
scrollIntoView(readyElement(by));
waitForNotificationsGone();
new Actions(getDriver()).moveToElement(readyElement(by))
.click()
.sendKeys(Keys.chord(Keys.CONTROL, "a"))
Expand Down Expand Up @@ -191,7 +192,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

0 comments on commit 751aba2

Please sign in to comment.