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

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.tests.tb3.SingleBrowserTest;

public class FocusShortcutsTest extends SingleBrowserTest {

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

        WebElement body = findElement(By.xpath("//body"));
        Actions actions = new Actions(getDriver());
        actions.keyDown(body, Keys.LEFT_ALT).sendKeys("a").keyUp(Keys.LEFT_ALT)
                .build().perform();

        Assert.assertEquals("1. Alt+A", getLogRow(0));

        body.click();

        actions = new Actions(getDriver());
        actions.keyDown(body, Keys.LEFT_ALT).sendKeys("n").keyUp(Keys.LEFT_ALT)
                .build().perform();

        Assert.assertEquals("2. Alt+N", getLogRow(0));

        body.click();

        actions = new Actions(getDriver());
        actions.keyDown(body, Keys.LEFT_CONTROL).keyDown(body, Keys.LEFT_SHIFT)
                .sendKeys("d").keyUp(Keys.LEFT_CONTROL).keyUp(Keys.LEFT_SHIFT)
                .build().perform();

        Assert.assertEquals("3. Ctrl+Shift+D", getLogRow(0));
    }

}