From a580558a68404f2b56c92fd6da9752e2bdfb33b1 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 13 Jul 2016 15:37:13 +0300 Subject: 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 --- .../components/tabsheet/TabsheetScrollingTest.java | 18 +++++++++++++++--- 1 file 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")); } } -- cgit v1.2.3