From 323d43711c572d7d676e044f1720fcc419a3c9d6 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 25 Aug 2016 12:57:37 +0300 Subject: Update ComboBox for new DataSource and communication mechanism This simplifies the client side state machine. This change does not modify the CSS class name v-filterselect. Change-Id: I2f4a6e5252045cb7698d582be90693e00961b342 --- .../testbench/customelements/ComboBoxElement.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java (limited to 'uitest-common/src/main') diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java new file mode 100644 index 0000000000..0f3b7b9d42 --- /dev/null +++ b/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java @@ -0,0 +1,61 @@ +package com.vaadin.testbench.customelements; + +import org.junit.Assert; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elementsbase.ServerClass; + +@ServerClass("com.vaadin.ui.ComboBox") +public class ComboBoxElement + extends com.vaadin.testbench.elements.ComboBoxElement { + + private static org.openqa.selenium.By bySuggestionPopup = By + .vaadin("#popup"); + + public WebElement getInputField() { + return findElement(By.vaadin("#textbox")); + } + + @Override + public String getText() { + return getInputField().getAttribute("value"); + } + + @Override + public void clear() { + getInputField().clear(); + } + + public WebElement getSuggestionPopup() { + return findElement(bySuggestionPopup); + } + + @Override + public void sendKeys(CharSequence... keysToSend) { + sendKeys(50, keysToSend); + } + + /** + * Use this method to simulate typing into an element, which may set its + * value. + * + * @param delay + * delay after sending each individual key (mainly needed for + * PhantomJS) + * @param keysToSend + * keys to type into the element + */ + public void sendKeys(int delay, CharSequence... keysToSend) { + WebElement input = getInputField(); + + for (CharSequence key : keysToSend) { + input.sendKeys(key); + try { + Thread.sleep(delay); + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } + } + } +} -- cgit v1.2.3