美文网首页
selenium元素定位异常总结

selenium元素定位异常总结

作者: 0981b16f19c7 | 来源:发表于2019-08-20 09:19 被阅读0次

1、报错:“selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable”

# 报错代码
driver.get(r'https://www.baidu.com/')
element = driver.find_element_by_tag_name('input').send_keys('selenium')
driver.quit()

原因分析:查看页面源码,知input标签的第一个元素的type='hidden',因此无法向改隐藏元素发送cliick或send_keys事件。


页面分析.png

解决方案:采用其他定位方式即可。

备注:有时候会存在目标的元素在当前页面不可见,需要拖动下拉框才能看到并进行操作。

相关文章

网友评论

      本文标题:selenium元素定位异常总结

      本文链接:https://www.haomeiwen.com/subject/iduesctx.html