Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 发送密钥属性错误,请回答我的问题_Python_Selenium_Python 3.9 - Fatal编程技术网

Python 发送密钥属性错误,请回答我的问题

Python 发送密钥属性错误,请回答我的问题,python,selenium,python-3.9,Python,Selenium,Python 3.9,错误: 搜索。发送按键(“耳机”) AttributeError:“WebElement”对象没有“发送密钥”属性 应该是发送键,而不是发送键。没有名为send\u Keys的方法。以下是您的代码的更正版本: from selenium import webdriver from selenium.webdriver.common.keys import Keys PATH = "C:\Program Files (x86)\chromedriver.exe" drive

错误:

搜索。发送按键(“耳机”)
AttributeError:“WebElement”对象没有“发送密钥”属性

应该是
发送键
,而不是
发送键
。没有名为
send\u 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()
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()