send_Keys 属性错误请回答我的问题

send_Keys Attribute Error pls any Answer my question

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

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

driver = webdriver.Chrome(executable_path=PATH)
driver.get("https://www.amazon.in/")
search = driver.find_element_by_name("field-keywords")
search.send_Keys("headphone")
search.send_Keys(Keys.RETURN)
click = driver.find_element_by_id("nav-search-submit-text").click()

driver.close()

错误:

  search.send_Keys("headphone")
AttributeError:'WebElement' object has no attribute 'send_Keys'

应该是send_keys,不是send_Keys。没有名为 send_Keys 的方法。这是您的代码的更正版本:

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

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

driver = webdriver.Chrome(executable_path=PATH)
driver.get("https://www.amazon.in/")
search = driver.find_element_by_name("field-keywords")
search.send_keys("headphone")
search.send_keys(Keys.RETURN)
click = driver.find_element_by_id("nav-search-submit-text").click()

driver.close()