AttributeError: 'WebElement' object has no attribute 'send_Keys' python selenium

AttributeError: 'WebElement' object has no attribute 'send_Keys' python selenium

代码:

from selenium import webdriver
import webbrowser

driver = webdriver.Chrome(r"C:\Users\nafi.DESKTOP-Q4U6HNF\Desktop\chromedriver.exe")

driver.get("https://www.youtube.com")


driver.find_element_by_css_selector("ytd-searchbox").send_Keys("venom")

driver.find_element_by_css_selector("search-icon-legacy > yt-icon").click()

main()

错误:

AttributeError: 'WebElement' object has no attribute 'send_Keys'

发送键将作用于输入字段。您正在尝试在 ytd-searchbox 上发送密钥,但这将不起作用。

尝试在以下元素上发送密钥

driver.find_element_by_xpath("//input[@id='search']").send_Keys("venom")

请使用'send_keys'(所有小写字母)而不是'send_Keys'。

例如。 element.send_keys("一些文字")