aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClippedTest.java
blob: 20504b79f95b580a6455085a3cead6e97a1cd02e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.vaadin.tests.components.tabsheet;

import static org.junit.Assert.assertEquals;

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.TabSheetElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class FirstTabNotVisibleWhenTabsheetNotClippedTest
        extends MultiBrowserTest {
    @Test
    public void testNotClippedTabIsVisible() throws InterruptedException {
        openTestURL();

        ButtonElement toggleNotClipped = $(ButtonElement.class)
                .caption("Toggle first not clipped tab").first();

        toggleNotClipped.click();
        TabSheetElement notClippedTabSheet = $(TabSheetElement.class).get(0);
        WebElement firstTab = notClippedTabSheet
                .findElement(By.className("v-tabsheet-tabitemcell-first"));
        String caption = firstTab.findElement(By.className("v-captiontext"))
                .getText();
        assertEquals("Tab with -first style should be Tab 1", "Tab 1", caption);

        toggleNotClipped.click();
        firstTab = notClippedTabSheet
                .findElement(By.className("v-tabsheet-tabitemcell-first"));
        caption = firstTab.findElement(By.className("v-captiontext")).getText();
        assertEquals("Tab with -first style should be Tab 0", "Tab 0", caption);
    }

    @Test
    public void testShowPreviouslyHiddenTab() {
        openTestURL();

        $(ButtonElement.class).caption("show tab D").get(0).click();
        $(ButtonElement.class).caption("show tab C").get(0).click();

        WebElement firstTab = $(TabSheetElement.class).get(2)
                .findElement(By.className("v-tabsheet-tabitemcell-first"));
        String firstCaption = firstTab
                .findElement(By.className("v-captiontext")).getText();

        org.junit.Assert.assertEquals("tab C", firstCaption);

        $(ButtonElement.class).caption("show tab D").get(1).click();
        $(ButtonElement.class).caption("show tab C").get(1).click();

        WebElement secondTab = $(TabSheetElement.class).get(3)
                .findElement(By.className("v-tabsheet-tabitemcell-first"));
        String secondCaption = secondTab
                .findElement(By.className("v-captiontext")).getText();

        org.junit.Assert.assertEquals("tab C", secondCaption);
    }
}