Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Selenium send_key can't type numbers like 5 or 6

So I see this issue on google selenium site but it has not been resolved yet.

when you element.send_key('12345')

it will return '123'. The 5 is parsed as backspace....

is there a work around for this?

Using latest selenium, chrome, chromedriver, python 2.7, ubuntu 12.04

like image 239
user299709 Avatar asked May 06 '15 10:05

user299709


2 Answers

I had this issue as well. It ended up being due to the VNC client (tightVNC) I had installed on my remote Ubuntu (16.04) instance.

I followed the advice here (https://bugs.chromium.org/p/chromedriver/issues/detail?id=1037) and removed tightVNC. I installed vnc4server and that seemed to solve the unusual behavior of being unable to pass on specific numbers.

like image 80
Epiwin Avatar answered Nov 11 '22 12:11

Epiwin


I do not have the chromedriver, so I cannot test this, but an other way to type the number 5 is to use the following command:

Keys.NUMPAD5

Your code would look something like this:

element.send_keys(Keys.NUMPAD5)

PS: Sending '5' works fine on the FirefoxDriver, as do the above commands

like image 40
esoleco Avatar answered Nov 11 '22 12:11

esoleco