aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java
blob: 289a5988ee9d1fcd65e21818f7fba210d9d96da4 (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.datefield;


import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.AbstractTB3Test;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import org.openqa.selenium.Keys;

import java.io.IOException;

public class DateFieldReadOnlyTest extends MultiBrowserTest {

    @Test
    public void readOnlyDateFieldPopupShouldNotOpen() throws IOException, InterruptedException {
        openTestURL();

        compareScreen("initial");
        toggleReadOnly();

        openPopup();
        compareScreen("readwrite-popup");

        closePopup();
        toggleReadOnly();
        compareScreen("readonly");
    }

    private void closePopup() {
        findElement(By.className("v-datefield-calendarpanel")).sendKeys(Keys.RETURN);
    }

    private void openPopup() {
        //waiting for openPopup() in TB4 beta1: http://dev.vaadin.com/ticket/13766
        $(DateFieldElement.class).first().findElement(By.tagName("button")).click();
    }

    private void toggleReadOnly() {
        $(ButtonElement.class).caption("Switch read-only").first().click();
    }
}