aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldShortcutTest.java
blob: 3e01a41b432231185567d323df2adbcfc6bab353 (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
package com.vaadin.tests.components.datefield;

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

import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

import static org.junit.Assert.assertEquals;

public class DateFieldShortcutTest extends SingleBrowserTest {

    private static final String DATEFIELD_VALUE_ORIGINAL = "11/01/2018";
    private static final String DATEFIELD_VALUE_MODIFIED = "21/01/2018";

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

        DateFieldElement dateField = $(DateFieldElement.class).first();
        WebElement dateFieldText = dateField.findElement(By.tagName("input"));

        assertEquals("DateField value should be \"" + DATEFIELD_VALUE_ORIGINAL
                + "\"", DATEFIELD_VALUE_ORIGINAL, dateField.getValue());

        dateFieldText.click();
        dateFieldText.sendKeys(Keys.HOME, Keys.DELETE, "2");
        dateFieldText.sendKeys(Keys.ENTER);

        assertEquals("DateField value should be \"" + DATEFIELD_VALUE_MODIFIED
                + "\"", DATEFIELD_VALUE_MODIFIED, dateField.getValue());

        assertEquals(DATEFIELD_VALUE_MODIFIED,
                $(NotificationElement.class).first().getCaption());
    }
}