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

Commit

Permalink
Code review changes:
Browse files Browse the repository at this point in the history
Add comment on test case purpose.
Remove method on WebElementUtils so that it doesn't cause troubles with dynamically loaded tables.
Dynamically load glossary page link, as it might not be there for certain users.
  • Loading branch information
Carlos A. Munoz committed Feb 5, 2014
1 parent 9395eda commit 3c1c75e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 2 additions & 4 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -63,9 +63,6 @@ public class BasePage extends CorePage {
@FindBy(id = "languages_link")
private WebElement languagesLink;

@FindBy(id = "glossary_link")
private WebElement glossaryLink;

@FindBy(id = "user--avatar")
private WebElement userAvatar;

Expand Down Expand Up @@ -97,7 +94,8 @@ public VersionGroupsPage goToGroups() {
}

public GlossaryPage goToGlossary() {
glossaryLink.click();
// Dynamically find the link, as it is not present for every user
getDriver().findElement(By.id("glossary_link")).click();
return new GlossaryPage(getDriver());
}

Expand Down
22 changes: 9 additions & 13 deletions functional-test/src/main/java/org/zanata/util/WebElementUtil.java
Expand Up @@ -153,26 +153,21 @@ public static FluentWait<WebDriver> waitForTenSeconds(WebDriver webDriver) {

public static List<String> getColumnContents(WebDriver driver, final By by,
final int columnIndex) {
WebElement table;
try {
table = driver.findElement(by);
} catch (NoSuchElementException noElement) {
// Some pages don't show a table, if there's no
// items to show
return Collections.emptyList();
}
return getColumnContents(driver, table, columnIndex);
}

public static List<String> getColumnContents(WebDriver driver,
final WebElement table, final int columnIndex) {
return waitForTenSeconds(driver).until(
new Function<WebDriver, List<String>>() {
@Override
public List<String> apply(@Nullable WebDriver input) {
if (input == null) {
throw new RuntimeException("Driver is null");
}
WebElement table;
try {
table = input.findElement(by);
} catch (NoSuchElementException noElement) {
// Some pages don't show a table, if there's no
// items to show
return Collections.emptyList();
}
List<WebElement> rows =
table.findElements(By.xpath(".//tbody[1]/tr"));
List<TableRow> tableRows =
Expand All @@ -193,6 +188,7 @@ public String apply(TableRow from) {
}));
}
});

}

public static List<List<String>> getTwoDimensionList(WebDriver driver,
Expand Down
Expand Up @@ -54,6 +54,14 @@ public class GlossaryAdminTest {

private ClientPushWorkFlow clientPushWorkFlow = new ClientPushWorkFlow();

/**
* Validates that a pushed glossary appears in the Glossary table.
* After pushing, a table with Glossary statistics should be shown.
* Validate that the the number of glossary entries per language matches
* the number of entries pushed from each of the test cases metnioned in the
* Setup.
* @see TCMS Test Case 181711
*/
@Test
public void testGlossaryView() {
// Push a glossary
Expand Down

0 comments on commit 3c1c75e

Please sign in to comment.