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

import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.openqa.selenium.Keys;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class UncloseableWindowCloseShortcutTest extends SingleBrowserTest {

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

        // Hit esc and verify that the Window was not closed.
        driver.findElement(By.cssSelector(".v-window-contents .v-scrollable"))
                .sendKeys(Keys.ESCAPE);
        assertTrue(
                "Uncloseable Window should remain open after esc is pressed.",
                isWindowOpen());
    }

    private boolean isWindowOpen() {
        return $(WindowElement.class).exists();
    }

}