You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NativeSelectsAndChromeKeyboardNavigationTest.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  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
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.nativeselect;
  17. import java.util.List;
  18. import org.junit.Assert;
  19. import org.junit.Test;
  20. import org.openqa.selenium.By;
  21. import org.openqa.selenium.Keys;
  22. import org.openqa.selenium.WebElement;
  23. import org.openqa.selenium.interactions.Actions;
  24. import org.openqa.selenium.remote.DesiredCapabilities;
  25. import com.vaadin.testbench.parallel.Browser;
  26. import com.vaadin.tests.tb3.MultiBrowserTest;
  27. public class NativeSelectsAndChromeKeyboardNavigationTest extends
  28. MultiBrowserTest {
  29. @Override
  30. public List<DesiredCapabilities> getBrowsersToTest() {
  31. return getBrowserCapabilities(Browser.CHROME);
  32. }
  33. @Test
  34. public void testValueChangeListenerWithKeyboardNavigation()
  35. throws InterruptedException {
  36. setDebug(true);
  37. openTestURL();
  38. Thread.sleep(1000);
  39. menu("Component");
  40. menuSub("Listeners");
  41. menuSub("Value change listener");
  42. getDriver().findElement(By.tagName("body")).click();
  43. WebElement select = getDriver().findElement(By.tagName("select"));
  44. select.sendKeys(Keys.ARROW_DOWN);
  45. select.sendKeys(Keys.ARROW_DOWN);
  46. select.sendKeys(Keys.ARROW_DOWN);
  47. String bodytext = getDriver().findElement(By.tagName("body")).getText();
  48. Assert.assertTrue(bodytext.contains("new value: 'Item 1'"));
  49. Assert.assertTrue(bodytext.contains("new value: 'Item 2'"));
  50. Assert.assertTrue(bodytext.contains("new value: 'Item 3'"));
  51. }
  52. @Override
  53. protected Class<?> getUIClass() {
  54. return NativeSelects.class;
  55. }
  56. private void menuSub(String string) {
  57. getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
  58. .click();
  59. new Actions(getDriver()).moveByOffset(100, 0).build().perform();
  60. }
  61. private void menu(String string) {
  62. getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
  63. .click();
  64. }
  65. }