2 * Copyright 2000-2014 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.Collections;
19 import java.util.List;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.openqa.selenium.By;
24 import org.openqa.selenium.Keys;
25 import org.openqa.selenium.WebElement;
26 import org.openqa.selenium.interactions.Actions;
27 import org.openqa.selenium.remote.DesiredCapabilities;
29 import com.vaadin.tests.tb3.MultiBrowserTest;
36 public class NativeSelectsAndChromeKeyboardNavigationTest extends
42 * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest()
45 public List<DesiredCapabilities> getBrowsersToTest() {
46 return Collections.singletonList(Browser.CHROME
47 .getDesiredCapabilities());
51 public void testValueChangeListenerWithKeyboardNavigation()
52 throws InterruptedException {
58 menuSub("Value change listener");
60 getDriver().findElement(By.tagName("body")).click();
62 WebElement select = getDriver().findElement(By.tagName("select"));
63 select.sendKeys(Keys.ARROW_DOWN);
64 select.sendKeys(Keys.ARROW_DOWN);
65 select.sendKeys(Keys.ARROW_DOWN);
67 String bodytext = getDriver().findElement(By.tagName("body")).getText();
69 Assert.assertTrue(bodytext.contains("new value: 'Item 1'"));
70 Assert.assertTrue(bodytext.contains("new value: 'Item 2'"));
71 Assert.assertTrue(bodytext.contains("new value: 'Item 3'"));
78 * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass()
81 protected Class<?> getUIClass() {
82 return NativeSelects.class;
89 private void menuSub(String string) {
90 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
92 new Actions(getDriver()).moveByOffset(100, 0).build().perform();
99 private void menu(String string) {
100 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))