Search code examples
pythonseleniumwebdriverattributeerror

Attribute Error: 'list' object has no attribute 'send_Keys' - Selenium


Im trying to open up the link in my code , locate where it asks me to enter my email address and then enter in my email address and finally press enter. However I am getting an attribute error: 'list' object has no attribute 'send_Keys' and have no idea why.

Here is my code:

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

PATH = "/Users/Monkeys/Downloads/chromedriver"
driver = webdriver.Chrome(PATH)

driver.get("https://www.mytutor.co.uk/tutors/login/")
search = driver.find_elements_by_name("form:email:input")
search.send_keys("[email protected]")
search.send_Keys(Keys.RETURN)

driver.quit()

I have tried to find the element in other ways still getting the same error. I thought I had issues locating the element in the HTML code but that wasn't the issue. I simply have no idea what the attribute error in this context means. I would appreciate if I could get some assistance please.


Solution

  • driver.find_elements_by_name("form:email:input")
    

    will return a list not a single web element. so search is a list in your case not a web element.

    send_keys 
    

    from selenium is meant for WebElement.

    use find_element instead that will return a WebElement not list of web elements.

    search = driver.find_element_by_name("form:email:input")