aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldAriaTest.java
blob: 83f0a7103d7c27f38557b347ae2679beeacee24a (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.vaadin.tests.components.datefield;

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

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.elements.InlineDateFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class DateFieldAriaTest extends SingleBrowserTest {

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

        DateFieldElement dateField = $(DateFieldElement.class).first();
        dateField.openPopup();
        WebElement prevMonthButton = driver
                .findElement(By.className("v-datefield-popup"))
                .findElement(By.className("v-button-prevmonth"));

        Assert.assertEquals("Previous month",
                prevMonthButton.getAttribute("aria-label"));

        dateField.openPopup(); // This actually closes the calendar popup

        ButtonElement changeLabelsButton = $(ButtonElement.class).first();
        changeLabelsButton.click();

        dateField.openPopup();
        prevMonthButton = driver.findElement(By.className("v-datefield-popup"))
                .findElement(By.className("v-button-prevmonth"));

        Assert.assertEquals("Navigate to previous month",
                prevMonthButton.getAttribute("aria-label"));
    }

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

        InlineDateFieldElement dateField = $(InlineDateFieldElement.class)
                .first();
        WebElement nextMonthElement = dateField
                .findElement(By.className("v-button-nextmonth"));

        Assert.assertEquals("Next month",
                nextMonthElement.getAttribute("aria-label"));

        ButtonElement changeLabelsButton = $(ButtonElement.class).first();
        changeLabelsButton.click();

        Assert.assertEquals("Navigate to next month",
                nextMonthElement.getAttribute("aria-label"));
    }
}