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

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

import com.vaadin.testbench.annotations.RunLocally;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class CloseWindowWithFocusedTextFieldTest extends MultiBrowserTest {

    @Test
    public void OpenWindow_CloseWithEscapeKey_WindowClosed() {
        openTestURL();
        $(ButtonElement.class).first().click();
        assertTrue("Window should be opened", $(WindowElement.class).exists());

        new Actions(getDriver()).sendKeys(Keys.ESCAPE).build().perform();
        assertFalse("Window found when there should be none.",
                $(WindowElement.class).exists());
    }

}