aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java
blob: 5d2a6e931033ab7ac441a11f8d7b8bf4e62f48ab (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
60
61
62
63
64
65
66
67
package com.vaadin.v7.tests.components.nativeselect;

import static org.junit.Assert.assertTrue;

import java.util.List;

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 org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class NativeSelectsAndChromeKeyboardNavigationTest
        extends MultiBrowserTest {

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        return getBrowserCapabilities(Browser.CHROME);
    }

    @Test
    public void testValueChangeListenerWithKeyboardNavigation()
            throws InterruptedException {
        setDebug(true);
        openTestURL();
        Thread.sleep(1000);
        menu("Component");
        menuSub("Listeners");
        menuSub("Value change listener");

        getDriver().findElement(By.tagName("body")).click();

        WebElement select = getDriver().findElement(By.tagName("select"));
        select.sendKeys(Keys.ARROW_DOWN);
        select.sendKeys(Keys.ARROW_DOWN);
        select.sendKeys(Keys.ARROW_DOWN);

        String bodytext = getDriver().findElement(By.tagName("body")).getText();

        assertTrue(bodytext.contains("new value: 'Item 1'"));
        assertTrue(bodytext.contains("new value: 'Item 2'"));
        assertTrue(bodytext.contains("new value: 'Item 3'"));

    }

    @Override
    protected Class<?> getUIClass() {
        return NativeSelects.class;
    }

    private void menuSub(String string) {
        getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
                .click();
        new Actions(getDriver()).moveByOffset(100, 0).build().perform();
    }

    private void menu(String string) {
        getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
                .click();

    }

}