2 * Copyright 2000-2016 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.tests.components.nativeselect;
18 import java.util.List;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.Keys;
24 import org.openqa.selenium.WebElement;
25 import org.openqa.selenium.interactions.Actions;
26 import org.openqa.selenium.remote.DesiredCapabilities;
28 import com.vaadin.testbench.parallel.Browser;
29 import com.vaadin.tests.tb3.MultiBrowserTest;
31 public class NativeSelectsAndChromeKeyboardNavigationTest
32 extends MultiBrowserTest {
35 public List<DesiredCapabilities> getBrowsersToTest() {
36 return getBrowserCapabilities(Browser.CHROME);
40 public void testValueChangeListenerWithKeyboardNavigation()
41 throws InterruptedException {
47 menuSub("Value change listener");
49 getDriver().findElement(By.tagName("body")).click();
51 WebElement select = getDriver().findElement(By.tagName("select"));
52 select.sendKeys(Keys.ARROW_DOWN);
53 select.sendKeys(Keys.ARROW_DOWN);
54 select.sendKeys(Keys.ARROW_DOWN);
56 String bodytext = getDriver().findElement(By.tagName("body")).getText();
58 Assert.assertTrue(bodytext.contains("new value: 'Item 1'"));
59 Assert.assertTrue(bodytext.contains("new value: 'Item 2'"));
60 Assert.assertTrue(bodytext.contains("new value: 'Item 3'"));
65 protected Class<?> getUIClass() {
66 return NativeSelects.class;
69 private void menuSub(String string) {
70 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
72 new Actions(getDriver()).moveByOffset(100, 0).build().perform();
75 private void menu(String string) {
76 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))