How can I simulate the ENTER key press using selenium python bindings? I have tried the following block but it is not working.
driver.find_element_by_xpath("html/xxxxx").send_keys('keys.ENTER')
or
driver.find_element_by_name("element_name").send_keys("ENTER")
We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys.
We can send keyboard input to a textbox on a webpage in Selenium webdriver in Python using the method send_keys. The text to be entered is passed as a parameter to that method. To perform keyboard actions, we can also use the send_keys method and then pass the class Keys.
Use these codes from the API docs: http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.keys
Eg. ENTER would be .send_keys(u'\ue007')
Try keys.ENTER
, not as a string (take the single quotes off).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With