不能发送_Keys到selenium python?

时间:2017-10-22 23:55:48

标签: python selenium-webdriver

driver= webdriver.Chrome()

driver.get("http://www.dsvv.ac.in/")

search= driver.find_elements_by_id('site-search')

search.send_Keys('meditation')

'list' object has no attribute 'send_Keys' error shows when try to find element by find_elements_by_id('site-search')

'WebElement' object has no attribute 'send_Keys'  error shows when try to find element by find_element_by_id('site-search').

当尝试仅发送密钥时显示错误,否则它可以正常工作。 任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

实际上,问题出在这里:

search= driver.find_elements_by_id('site-search')

find_elements_by_id将返回一个列表,而不是一个元素。使用

search= driver.find_element_by_id('site-search')

(注意缺失的s)或

search[0].send_keys('meditation')