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

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
- Some tests failing for objects not in focus
- Timing issues
- Some logic broke with last defocus change
  • Loading branch information
djansen-redhat committed May 14, 2014
1 parent 402c73e commit 1cb216a
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 214 deletions.
11 changes: 11 additions & 0 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -93,6 +93,7 @@ public ProjectsPage goToProjects() {
}

private void clickNavMenuItem(final WebElement menuItem) {
scrollIntoView(menuItem);
if (!menuItem.isDisplayed()) {
// screen is too small the menu become dropdown
getDriver().findElement(By.id("nav-main"))
Expand Down Expand Up @@ -153,6 +154,7 @@ public String loggedInAs() {
}

public HomePage logout() {
scrollIntoView(userAvatar);
userAvatar.click();

clickLinkAfterAnimation(BY_SIGN_OUT);
Expand Down Expand Up @@ -296,4 +298,13 @@ public String getHtmlSource(WebElement webElement) {
"return arguments[0].innerHTML;", webElement);
}

public void scrollIntoView(WebElement targetElement) {
((JavascriptExecutor) getDriver()).executeScript(
"arguments[0].scrollIntoView(true);", targetElement);
}

public void clickElement(By findby) {
scrollIntoView(getDriver().findElement(findby));
getDriver().findElement(findby).click();
}
}
Expand Up @@ -22,8 +22,10 @@

import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.zanata.page.projects.ProjectBasePage;

Expand Down Expand Up @@ -57,9 +59,6 @@ public class ProjectGeneralTab extends ProjectBasePage {
@FindBy(id = "settings-general-form:repoField:repo")
private WebElement repoField;

@FindBy(id = "settings-general-form:button-update-settings")
private WebElement updateButton;

public ProjectGeneralTab(WebDriver driver) {
super(driver);
}
Expand Down Expand Up @@ -107,7 +106,9 @@ public ProjectGeneralTab enterDescription(String projectDescription) {
*/
public ProjectGeneralTab selectProjectType(String projectType) {
assert getProjectTypes().containsKey(projectType);
getProjectTypes().get(projectType).click();
WebElement projectTypeButton = getProjectTypes().get(projectType);
scrollIntoView(projectTypeButton);
projectTypeButton.click();
return new ProjectGeneralTab(getDriver());
}

Expand Down Expand Up @@ -158,9 +159,7 @@ public boolean isArchiveButtonAvailable() {
* @return new Project General Settings page
*/
public ProjectGeneralTab archiveProject() {
getDriver().findElement(
By.id("settings-general-form:button-archive-project"))
.click();
clickElement(By.id("settings-general-form:button-archive-project"));
return new ProjectGeneralTab(getDriver());
}

Expand All @@ -169,9 +168,7 @@ public ProjectGeneralTab archiveProject() {
* @return new Project General Settings page
*/
public ProjectGeneralTab unarchiveProject() {
getDriver().findElement(
By.id("settings-general-form:button-unarchive-project"))
.click();
clickElement(By.id("settings-general-form:button-unarchive-project"));
return new ProjectGeneralTab(getDriver());
}

Expand All @@ -180,9 +177,7 @@ public ProjectGeneralTab unarchiveProject() {
* @return new Project General Settings page
*/
public ProjectGeneralTab lockProject() {
getDriver().findElement(
By.id("settings-general-form:button-lock-project"))
.click();
clickElement(By.id("settings-general-form:button-lock-project"));
return new ProjectGeneralTab(getDriver());
}

Expand All @@ -191,9 +186,7 @@ public ProjectGeneralTab lockProject() {
* @return new Project General Settings page
*/
public ProjectGeneralTab unlockProject() {
getDriver().findElement(
By.id("settings-general-form:button-unlock-project"))
.click();
clickElement(By.id("settings-general-form:button-unlock-project"));
return new ProjectGeneralTab(getDriver());
}

Expand Down Expand Up @@ -224,7 +217,14 @@ public ProjectGeneralTab enterRepository(String repo) {
* @return new Project General Settings page
*/
public ProjectGeneralTab updateProject() {
clickAndCheckErrors(updateButton);
scrollIntoView(updateButton());
clickAndCheckErrors(updateButton());
return new ProjectGeneralTab(getDriver());
}

private WebElement updateButton() {
return getDriver().findElement(
By.id("settings-general-form:button-update-settings"));
}

}
Expand Up @@ -34,6 +34,10 @@

public class CreateVersionPage extends BasePage {

public final static String VALIDATION_ERROR =
"must start and end with letter or number, "
+ "and contain only letters, numbers, underscores and hyphens.";

@FindBy(id = "create-version-form:project-type")
private WebElement projectTypeSelection;

Expand Down
Expand Up @@ -39,7 +39,7 @@
import org.zanata.workflow.LoginWorkFlow;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.zanata.util.FunctionalTestHelper.assumeFalse;
import static org.zanata.util.FunctionalTestHelper.assumeTrue;

/**
* @author Damian Jansen <a
Expand All @@ -64,7 +64,11 @@ public void before() {
CleanDocumentStorageRule.getDocumentStoragePath()
.concat(File.separator).concat("documents")
.concat(File.separator);
assumeFalse("", new File(documentStorageDirectory).exists());
File docStorage = new File(documentStorageDirectory);
assumeTrue("The storage folder is empty",
docStorage == null ||
!docStorage.exists() ||
docStorage.listFiles().length == 0);
}

@Test
Expand All @@ -85,9 +89,9 @@ public void uploadHTMLFile() {
.pressUploadFileButton()
.enterFilePath(htmlfile.getAbsolutePath())
.submitUpload();

assertThat("Document uploaded notification shows",
projectVersionPage.getNotificationMessage(),
Matchers.equalTo(successfullyUploaded));
projectVersionPage.expectNotification(successfullyUploaded));

VersionDocumentsPage versionDocumentsPage =
projectVersionPage.gotoDocumentTab();
Expand Down

0 comments on commit 1cb216a

Please sign in to comment.