Selenium Chromedriver not sending exclamation mark

Posted on

Update: The chromedriver team looked at the issues and currently they won’t fix it as it only happens with non US-en keyboards. So to fix it the computer on which chromedriver gets run must have this keyboard set for it to work without problems.

But they may implement a warning if the user doesn’t use the US-en keyboard so people won’t need to spend time debugging the issue.

package ch.robinglauser.seleniumtest;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class SeleniumTest {

    public static void main(String[] args) {
        String text = "Hello World!";
        System.setProperty("", "/usr/local/bin/chromdriver");
        ChromeOptions chromeOptions = new ChromeOptions();
        ChromeDriver browser = new ChromeDriver(chromeOptions);

        WebElement search = browser.findElement(By.cssSelector(".search-field"));


        synchronized (browser) {
            try {
                browser.wait(1000, 100000);
            } catch (InterruptedException e) {

You would expect the code above to print out the following:

Hello World!
Hello World!

But what it prints out is

Hello World
Hello World!

Which means that the exclamation point has gotten lost somewhere on the way after sending it via sendKeys to the driver. I’ve tested it and it’s the only sign that gets lost out of all those characters:


There is a solution to this, but it’s not really great and won’t work for all cases:

browser.executeScript("document.getElementsByClassName('search-field')[0].value = \"" + text + "\";");

I’ve debugged the issue with wireshark to see where the exclamation mark gets lost and apparently it gets sent to the chromedriver, so the issue will be somewhere in the driver and not with the Java implementation of selenium.

I’ve opened a new issue for chromedriver and apparently there are already a few similar but not identical issues.

Leave a Reply