aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZheSun88 <zhe@vaadin.com>2019-03-06 13:12:19 +0200
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2019-03-07 10:09:37 +0200
commitc6ad655490aa3fafc71e51bdf42496bc0869dbfb (patch)
tree3ce4bcdfe4fc9d5d109d5d0b892904e23fa82333
parente5d206f7980179c68e80f1316ec0005d9717380c (diff)
downloadvaadin-framework-c6ad655490aa3fafc71e51bdf42496bc0869dbfb.tar.gz
vaadin-framework-c6ad655490aa3fafc71e51bdf42496bc0869dbfb.zip
Fix ComboBoxElement clear method
Explicitly reset the value in case if it was cleared. Ignore the case for selecting a suggestion. Fixes vaadin/testbench#1122
-rw-r--r--testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java9
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java12
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java4
3 files changed, 11 insertions, 14 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java
index e000b0bddd..23b9a98502 100644
--- a/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java
+++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java
@@ -52,8 +52,8 @@ public class ComboBoxElement extends AbstractSingleSelectElement {
selectByTextFromPopup(text);
return;
}
- getInputField().clear();
- getInputField().sendKeys(text);
+ clear();
+ sendKeys(text);
selectSuggestion(text);
}
@@ -231,6 +231,11 @@ public class ComboBoxElement extends AbstractSingleSelectElement {
@Override
public void clear() {
getInputField().clear();
+ String value = getText();
+ if (value != null && !value.isEmpty()) {
+ ((JavascriptExecutor) getDriver())
+ .executeScript("arguments[0].value = ''", getInputField());
+ }
}
@Override
diff --git a/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java b/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java
index 647c9601e4..942e23f061 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java
@@ -147,17 +147,7 @@ public class ErrorLevelsTest extends SingleBrowserTest {
}
private void selectErrorLevel(ErrorLevel errorLevel) {
- errorLevelSelector.clear();
errorLevelSelector
- .sendKeys(errorLevel.toString().toLowerCase(Locale.ROOT));
- errorLevelSelector.sendKeys(getReturn());
- }
-
- private Keys getReturn() {
- if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
- return Keys.ENTER;
- } else {
- return Keys.RETURN;
- }
+ .selectByText(errorLevel.toString().toUpperCase(Locale.ROOT));
}
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java
index 1e2869df61..6f6d45cd2a 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java
@@ -137,7 +137,9 @@ public class ComboBoxSelectingNewItemValueChangeTest extends MultiBrowserTest {
protected void typeInputAndSelect(String input,
SelectionType selectionType) {
- comboBoxElement.clear();
+ // clear() would cause an additional value change in chrome 70+
+ // since it always makes blur after clear()
+ comboBoxElement.sendKeys(Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE);
sendKeysToInput(input);
switch (selectionType) {
case ENTER: