Selenium Python: send keys error


I ran into the following error when executing a Selenium script written in Python:

selenium.common.exceptions.WebDriverException: Message: Expected [object Undefined] undefined to be a string

Delving through the stacktrace, I found that the problem was coming from send_keys:

self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})

After researching the issue, I discovered that Firefox 53+ requires geckodriver 16+.

So I updated geckodriver with homebrew:

brew upgrade geckodriver

After running Selenium again, I received a new error:

KeyError: 'sessionId'

It turned out I also needed to upgrade the selenium Python package:

pip install selenium --upgrade

Now everything’s working again.



Please support this site and join our Discord!