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

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import static org.junit.Assert.assertTrue;

public class CloseWindowOnEscapeMaximizedButtonFocusedTest
        extends MultiBrowserTest {

    @Test
    public void windowIsClosed() {
        openTestURL();
        ButtonElement openWindow = $(ButtonElement.class).id("openW");
        openWindow.click();

        WindowElement window = $(WindowElement.class).first();
        window.maximize();
        findElement(By.className("v-window-restorebox")).sendKeys(Keys.ESCAPE);
        waitForElementNotPresent(By.className("v-window"));
        assertTrue("Window should be removed after ESC key is pressed",
                driver.findElements(By.className("v-window ")).isEmpty());
    }
}