Przeglądaj źródła

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
feature/vaadin8-book-vol2
Henri Sara 7 lat temu
rodzic
commit
f7e1d353dd

+ 15
- 3
uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java Wyświetl plik

@@ -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"));

}
}

Ładowanie…
Anuluj
Zapisz