selenium: [🐛 Bug]: Send_keys does not accept underscore when I use chromedriver 98

What happened?

I use a python binding of selenium. After updating the version of chromedriver from 97 to 98, I found that send_keys raised the following exception when I include underscore into the input value.

selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot construct KeyEvent from non-typeable key

Could anyone take a look at the problem? Thank you

Note: it may be reproducible only on macOS.

How can we reproduce the issue?

driver = webdriver.Chrome()
driver.get('https://www.google.com/')
search_box = driver.find_element_by_name("q")
search_box.send_keys('foo')
search_box.send_keys('foo_boo')

Relevant log output

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-20-4fe2e3e66933> in <module>
      3 search_box = driver.find_element_by_name("q")
      4 search_box.send_keys('foo')
----> 5 search_box.send_keys('foo_boo')

~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py in send_keys(self, *value)
    477         self._execute(Command.SEND_KEYS_TO_ELEMENT,
    478                       {'text': "".join(keys_to_typing(value)),
--> 479                        'value': keys_to_typing(value)})
    480 
    481     # RenderedWebElement Items

~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py in _execute(self, command, params)
    626             params = {}
    627         params['id'] = self._id
--> 628         return self._parent.execute(command, params)
    629 
    630     def find_element(self, by=By.ID, value=None):

~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    318         response = self.command_executor.execute(driver_command, params)
    319         if response:
--> 320             self.error_handler.check_response(response)
    321             response['value'] = self._unwrap_value(
    322                 response.get('value', None))

~/opt/anaconda3/envs/py37/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: Cannot construct KeyEvent from non-typeable key
  (Session info: chrome=98.0.4758.80)

Operating System

macOS

Selenium version

Python 3.13.0

What are the browser(s) and version(s) where you see this issue?

Google Chrome 98.0.4758.80

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 98.0.4758.48

Are you using Selenium Grid?

No

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

This is definitely a Chromedriver issue. I have recreated it with the selenium test suite.

I found something that might be related to the issue above on the chromedriver-users group: https://groups.google.com/g/chromedriver-users/c/8WTsbereIO4/m/_aeQGxN7AwAJ