diff options
-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")); } } |