1 package com.vaadin.tests.components.combobox;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.collection.IsEmptyCollection.empty;
9 import org.openqa.selenium.Keys;
10 import org.openqa.selenium.WebElement;
12 import com.vaadin.testbench.By;
13 import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
14 import com.vaadin.v7.testbench.customelements.ComboBoxElement;
16 public class ComboBoxEmptyItemsKeyboardNavigationTest
17 extends SingleBrowserTestPhantomJS2 {
20 public void navigatingUpOnAnEmptyMenuDoesntThrowErrors() {
24 ComboBoxElement combobox = $(ComboBoxElement.class).first();
25 combobox.sendKeys("a", Keys.ARROW_UP);
27 List<WebElement> errors = findElements(By.className("SEVERE"));
29 assertThat(errors, empty());
33 public void selectingUsingEnterInAnEmptyMenu() {
37 ComboBoxElement combobox = $(ComboBoxElement.class).first();
38 combobox.sendKeys("a", Keys.ENTER);
40 List<WebElement> errors = findElements(By.className("SEVERE"));
42 assertThat(errors, empty());
44 assertPopupClosed(combobox);
48 public void selectingUsingTabInAnEmptyMenu() {
52 ComboBoxElement combobox = $(ComboBoxElement.class).first();
53 // The joy of testing, one tab should be enough but is not (it is
54 // locally), two tabs does the trick for PhantomJS on the cluster...
55 combobox.sendKeys("abc", Keys.TAB, Keys.TAB);
57 List<WebElement> errors = findElements(By.className("SEVERE"));
59 assertThat(errors, empty());
60 assertPopupClosed(combobox);
63 private void assertPopupClosed(ComboBoxElement combobox) {
64 org.openqa.selenium.By bySuggestionPopup = By.vaadin("#popup");
66 assertThat("ComboBox popup should not be open",
67 combobox.findElements(bySuggestionPopup).isEmpty());