diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-05-19 11:37:36 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-05-20 19:31:22 +0000 |
commit | fd8a4d3ab839d7e29fe89ff7b4329a8776ae3304 (patch) | |
tree | 58c3e68f19c0f98415f166cb36bc767e9025c962 /uitest | |
parent | 13ddd2b03c99b563b131c115982ac09453ca749f (diff) | |
download | vaadin-framework-fd8a4d3ab839d7e29fe89ff7b4329a8776ae3304.tar.gz vaadin-framework-fd8a4d3ab839d7e29fe89ff7b4329a8776ae3304.zip |
Refactor tests to make them less likely to have timing issues
Change-Id: Idf24ab4f7c2c48f8246f0c38906d2b8a46f46587
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java | 16 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/table/TableSortingIndicatorTest.java | 37 |
2 files changed, 27 insertions, 26 deletions
diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java index 52ffc6b729..0c6f0abf3c 100644 --- a/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java @@ -23,7 +23,6 @@ import static org.hamcrest.Matchers.lessThan; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; -import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.PopupViewElement; @@ -45,21 +44,18 @@ public class PopupViewResizeWhileOpenTest extends MultiBrowserTest { // Open PopupView $(PopupViewElement.class).first().click(); - // Shadow element - WebElement shadow = findElement(By.className("v-shadow")); - WebElement vl = $(VerticalLayoutElement.class).id("content-vl"); - // Sanity check - assertShadowSize(vl, shadow); + assertShadowSize(); // Resize $(ButtonElement.class).first().click(); - assertShadowSize(vl, shadow); + assertShadowSize(); } - private void assertShadowSize(WebElement layout, WebElement shadow) { - Dimension shadowSize = shadow.getSize(); - Dimension layoutSize = layout.getSize(); + private void assertShadowSize() { + Dimension shadowSize = findElement(By.className("v-shadow")).getSize(); + Dimension layoutSize = $(VerticalLayoutElement.class).id("content-vl") + .getSize(); assertThat(shadowSize.height, is(greaterThan(layoutSize.height))); assertThat(shadowSize.height, is(lessThan(layoutSize.height + 10))); diff --git a/uitest/src/com/vaadin/tests/components/table/TableSortingIndicatorTest.java b/uitest/src/com/vaadin/tests/components/table/TableSortingIndicatorTest.java index 36a51b35e3..8453f5d67f 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableSortingIndicatorTest.java +++ b/uitest/src/com/vaadin/tests/components/table/TableSortingIndicatorTest.java @@ -17,9 +17,9 @@ package com.vaadin.tests.components.table; import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.WebElement; -import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -36,30 +36,35 @@ public class TableSortingIndicatorTest extends MultiBrowserTest { public void testTableSortingIndicatorIsVisibleAfterServersideSort() { openTestURL(); + ButtonElement button = $(ButtonElement.class).caption("Sort").first(); + TableElement table = $(TableElement.class).first(); + Assert.assertFalse("Descending indicator was prematurely visible", - isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR))); + getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); Assert.assertFalse("Ascending indicator was prematurely visible", - isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR))); - WebElement button = driver.findElement(By - .vaadin("//Button[caption=\"Sort\"]")); + getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); + button.click(); Assert.assertTrue("Indicator did not become visible", - isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR))); - + getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); Assert.assertFalse("Ascending sort indicator was wrongly visible", - isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR))); - WebElement manualSort = driver.findElement(By - .className(TABLE_HEADER_DESC_INDICATOR)); - manualSort.click(); + getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); + + table.getHeaderCell(0).click(); Assert.assertFalse("Table sort indicator didn't change", - isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR))); + getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); Assert.assertTrue("Ascending sort indicator didn't become visible", - isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR))); + getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); + button.click(); Assert.assertTrue( "Descending sort indicator didn't appear on the second serverside sort.", - isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR))); + getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); Assert.assertFalse("Ascending sort indicator didn't disappear", - isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR))); + getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); + } + + private String getHeaderClasses(TableElement table) { + return table.getHeaderCell(0).getAttribute("class"); } } |