diff options
author | Henri Sara <hesara@vaadin.com> | 2016-07-13 15:37:13 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-07-13 13:09:32 +0000 |
commit | a580558a68404f2b56c92fd6da9752e2bdfb33b1 (patch) | |
tree | 425337eb2c29d9fb104dce29df96378e695b07cf | |
parent | ce746e0a86f4b110d7c821cdc2542a9677b17367 (diff) | |
download | vaadin-framework-a580558a68404f2b56c92fd6da9752e2bdfb33b1.tar.gz vaadin-framework-a580558a68404f2b56c92fd6da9752e2bdfb33b1.zip |
Fix and optimize TabsheetScrollingTest
The test was based on the assumption that only the visible tabs are
in the DOM of the tab bar. This assumption was no longer true.
Furthermore, the test iterated over all tabs which led to performance
issues especially on IE8.
Change-Id: If8e904418bdb81cf2762475b317adb2b21dcc032
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java index 47753e09d3..42c384dd78 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java @@ -18,6 +18,7 @@ package com.vaadin.tests.components.tabsheet; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; +import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; @@ -40,7 +41,7 @@ public class TabsheetScrollingTest extends MultiBrowserTest { } private WebElement getTab(int index) { - return getDriver().findElement(By.vaadin("//TabSheet#tab[1]")); + return getDriver().findElement(By.vaadin("//TabSheet#tab["+index+"]")); } private String getHideButtonText() { @@ -52,16 +53,27 @@ public class TabsheetScrollingTest extends MultiBrowserTest { new Actions(getDriver()).sendKeys(key).perform(); } + private WebElement getTabByCaption(TabSheetElement ts, String caption) { + WebElement tabBar = ts.findElement(By.className("v-tabsheet-tabs")); + return tabBar.findElement(By.xpath("./tbody/tr/td[./div/div/div[contains(., normalize-space('"+caption+"'))]]")); + } + + private boolean isTabVisible(TabSheetElement ts, String tabCaption) { + WebElement tab = getTabByCaption(ts, tabCaption); + Point location = tab.getLocation(); + return location.getX() > 0 && location.getX() < ts.getSize().getWidth(); + } + @Test public void serverChangeShouldShowTab() { openTestURL(); $(ButtonElement.class).id(TabsheetScrolling.SELECT_LAST).click(); TabSheetElement tabsheetFixed = $(TabSheetElement.class).first(); Assert.assertTrue("Select last should scroll last tab into view", - tabsheetFixed.getTabCaptions().contains("Tab 99")); + isTabVisible(tabsheetFixed, "Tab 99")); $(ButtonElement.class).id(TabsheetScrolling.SELECT_FIRST).click(); Assert.assertTrue("Select first should scroll first tab into view", - tabsheetFixed.getTabCaptions().contains("Tab 1")); + isTabVisible(tabsheetFixed, "Tab 1")); } } |