[英]Can't send_Keys to selenium python?
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')
. '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').
Error shows when try to send keys only,otherwise it works fine. 尝试仅发送密钥时显示错误,否则可以正常工作。 Can anyone help me for this? 有人可以帮我吗?
Actually, the problem lies here: 实际上,问题出在这里:
search= driver.find_elements_by_id('site-search')
find_elements_by_id will return a list and not an element. find_elements_by_id将返回一个列表,而不是一个元素。 Either use 无论使用
search= driver.find_element_by_id('site-search')
(note the missing s) or (请注意缺少的)或
search[0].send_keys('meditation')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.