aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPositionTest.java
blob: b1a8ad6f94c339b9f14a7ee79f38a08bb854392f (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.textfield;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class InputPromptAndCursorPositionTest extends MultiBrowserTest {

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        // IE11 has a known bug with placeholders:
        // https://connect.microsoft.com/IE/feedback/details/811408
        return getBrowsersExcludingIE();
    }

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

        // Clear the current value and reveal the input prompt.
        TextFieldElement textFieldElement = $(TextFieldElement.class).get(0);
        textFieldElement.clear();

        // Update cursor position.
        $(ButtonElement.class).get(0).click();

        // The cursor position should now be zero (not the input prompt length).
        LabelElement cursorPosLabel = $(LabelElement.class).get(1);
        assertEquals("Cursor position: 0", cursorPosLabel.getText());
    }
}