Skip to content

Commit 9f2fd81

Browse files
committed
Reworking sendKeys to send characters one by one, this is standard compliant behavior
1 parent 678834e commit 9f2fd81

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

java/client/src/org/openqa/selenium/remote/RemoteWebElement.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,21 @@ public void submit() {
9090

9191
public void sendKeys(CharSequence... keysToSend) {
9292
File localFile = fileDetector.getLocalFile(keysToSend);
93-
if (localFile == null) {
94-
execute(DriverCommand.SEND_KEYS_TO_ELEMENT, ImmutableMap.of("id", id, "value", keysToSend));
95-
return;
93+
if (localFile != null) {
94+
String remotePath = upload(localFile);
95+
keysToSend = new CharSequence[]{remotePath};
96+
}
97+
98+
StringBuilder sb = new StringBuilder();
99+
for (CharSequence s : keysToSend) {
100+
sb.append(s);
101+
}
102+
103+
CharSequence[] keys = new CharSequence[sb.length()];
104+
for (int i = 0; i < sb.length(); i++) {
105+
keys[i] = Character.toString(sb.charAt(i));
96106
}
97107

98-
String remotePath = upload(localFile);
99-
CharSequence[] keys = new CharSequence[]{remotePath};
100108
execute(DriverCommand.SEND_KEYS_TO_ELEMENT, ImmutableMap.of("id", id, "value", keys));
101109
}
102110

0 commit comments

Comments
 (0)