aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/window/ExtraWindowShownTest.java
blob: 88f5215514a3af299f9455c02a11ed1f15f0236b (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
package com.vaadin.tests.components.window;

import static org.junit.Assert.assertFalse;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class ExtraWindowShownTest extends MultiBrowserTest {

    @Test
    public void testNoExtraWindowAfterClosing() throws Exception {
        openTestURL();

        openWindow();
        closeWindow();
        assertNoWindow();

        openWindow();
        closeWindow();
        assertNoWindow();
    }

    private void openWindow() {
        $(ButtonElement.class).first().click();
    }

    private void closeWindow() {
        $(WindowElement.class).$(ButtonElement.class).first().click();
    }

    private void assertNoWindow() {
        assertFalse("Window found when there should be none.",
                $(WindowElement.class).exists());
    }
}