Reputation: 11
I need to automate using webdriver to send keys followed by an enter. but the enter is not getting triggered. and this happens only on some machine. i tried increasing delays between the sendkeys and enter. both machines failing and passing 1 have same python packages/versions.
send_keys(Keys.ENTER) does not work on some machines.
ele = driver.find_element_by_xpath("xpath")
ele.send_keys("test")
time.sleep(2)
ActionChains(driver).send_keys(Keys.ENTER).perform()
i even tried ele.send_key(Keys.ENTER) and ele.send_key("\n"). but noting is working. tried increasing delays as well. but no luck
Upvotes: 1
Views: 2892
Reputation: 611
I would use something like pykeyboard for key-related issues like this. It's a useful backup at the very least.
The pykeyboard package allows you to automate keystrokes and hotkeys for various tasks. I often use it when Selenium gives me trouble with finding the appropriate elements or just not letting me send_keys at all.
I wrote-up an example this morning on the link here if you're interested:
How to implement key combinations (including modifier keys) in Python?
Good Luck.
Upvotes: 1