Browse Source

Remove sendKeys workaround from ComboBoxElement (#9046)

tags/8.1.0.alpha5
Aleksi Hietanen 7 years ago
parent
commit
03d1f69468

+ 1
- 27
testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java View File

@@ -20,7 +20,6 @@ import java.util.Collections;
import java.util.List;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

@@ -54,7 +53,7 @@ public class ComboBoxElement extends AbstractSelectElement {
return;
}
getInputField().clear();
sendInputFieldKeys(text);
getInputField().sendKeys(text);

selectSuggestion(text);
}
@@ -118,31 +117,6 @@ public class ComboBoxElement extends AbstractSelectElement {
return isElementPresent(bySuggestionPopup);
}

/*
* Workaround selenium's bug: sendKeys() will not send left parentheses
* properly. See #14048.
*/
private void sendInputFieldKeys(String text) {
WebElement textBox = getInputField();
if (!text.contains("(")) {
textBox.sendKeys(text);
return;
}

String OPEN_PARENTHESES = "_OPEN_PARENT#H#ESES_";
String tamperedText = text.replaceAll("\\(", OPEN_PARENTHESES);
textBox.sendKeys(tamperedText);

JavascriptExecutor js = getCommandExecutor();
String jsScript = String.format(
"arguments[0].value = arguments[0].value.replace(/%s/g, '(')",
OPEN_PARENTHESES);
js.executeScript(jsScript, textBox);

// refresh suggestions popupBox
textBox.sendKeys("a" + Keys.BACK_SPACE);
}

/**
* Open the suggestion popup
*/

Loading…
Cancel
Save