From 41ef058ba8a99d7603e98e122b9e60fa2dbf33c9 Mon Sep 17 00:00:00 2001 From: Sun Zhe <31067185+ZheSun88@users.noreply.github.com> Date: Wed, 6 Mar 2019 16:18:40 +0200 Subject: Fix ComboBoxElement clear method (#11483) Explicitly reset the value in case if it was cleared. Ignore the case for selecting a suggestion. Fixes vaadin/testbench#1122 --- .../main/java/com/vaadin/testbench/elements/ComboBoxElement.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'testbench-api/src/main/java/com/vaadin/testbench') 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 -- cgit v1.2.3