Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ENTER key press using Selenium WebDriver with python [duplicate]

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")
like image 489
user1537127 Avatar asked Jul 11 '16 16:07

user1537127


People also ask

How do you hit the Enter key in Selenium?

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.

How do I use keyboard keys in Selenium Python?

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.


2 Answers

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')

like image 124
Alichino Avatar answered Sep 20 '22 14:09

Alichino


Try keys.ENTER, not as a string (take the single quotes off).

like image 26
d_rez90 Avatar answered Sep 19 '22 14:09

d_rez90