I am using selenium package with Python (https://pypi.python.org/pypi/selenium) with Windows 7.
When I try to login to my facebook account I use the send_keys
command, e.g.
elem = browser.find_element_by_name("email")
elem.send_keys(email);
elem = browser.find_element_by_name("pass")
elem.send_keys(password);
Login fails apparently because the second send_keys
drops the first character of the password (I found this by directly sending the password characters to the email field.
What's going on? Why can't selenium do something so simple as sending keys to an input field? Is this some kind of a protection measure coded by Facebook to reject automatic scripting?
Tried to send the whole alphabet and got this:
abcdefghijklmnopqrstuvwxyzBCDFGIKLNOQSTWX
Notice how many characters are missing...
Update
Apparently the problem has nothing to do with facebook but to the chrome driver.
If I send the following simple code
browser = webdriver.Chrome()
browser.get("https://www.google.com") # Load page
elem = browser.find_element_by_name("q") # Find the query box
query= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
elem.send_keys(query)
With chrome driver I get
BCDFGIKLNOQSTWX
Notice how A, E, H ... Y, Z are missing
With firefox driver (replacing browser = webdriver.Chrome()
with browser = webdriver.Firefox()
I get:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Looks like there are (were) some bugs in the Chrome webdriver: https://code.google.com/p/chromedriver/issues/detail?id=435
The core of the problem looks to be when either the keyboard is configured for a non-English language, or if the webdriver process and the chrome display are running in different language/environments (e.g., when going through a remote display from one host to another, etc.)
Use selenium Ide and export test case in python
I've solved using a custom method for send_keys, which works a little bit lower but fast enough.