0

When I run my script it gives me this error:

Traceback (most recent call last):
  File "C:\Development\Python_Project\SDETpythonProject\SDET_Package\my_firstProject.py", line 18, in <module>
    search.send_keys(keys.RETURN)
AttributeError: module 'selenium.webdriver.common.keys' has no attribute 'RETURN'

Here is my code:

from selenium import webdriver
import selenium
from selenium.webdriver.common import keys
import time


# this will load googlechrome from the location in C-drive


PATH = "C:\Program Files (x86)\chromedriver.exe"

driver = webdriver.Chrome(PATH)

driver.get("https://techwithtim.net")
print(driver.title) # print the title of the page

search = driver.find_element_by_name("s")
search.send_keys("test")
search.send_keys(keys.RETURN)
time.sleep(5)
driver.close() # close the browser
0

See the documentation: https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html

instead of :

from selenium.webdriver.common import keys
search.send_keys(keys.RETURN) 

you need to use:

from selenium.webdriver.common.keys import Keys
search.send_keys(Keys.RETURN) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.