python NoSuchElementException异常处理
生活随笔
收集整理的这篇文章主要介绍了
python NoSuchElementException异常处理
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
python爬虫程序,用Selenium模拟点击时报出异常NoSuchElementException:Unable to locate......
出错原因:https://www.cnblogs.com/cttcarrotsgarden/p/11210883.html
异常通常发生于找不到目标元素的时候
导入Selenium的NoSuchElementException包
from selenium.common.exceptions import NoSuchElementExceptiontry:
xpath = ".//table//tr[1]//td[1]" browser.find_element_by_xpath(xpath).click() except NoSuchElementException:
print("没有找到元素!")
转载于:https://www.cnblogs.com/cttcarrotsgarden/p/11210919.html
总结
以上是生活随笔为你收集整理的python NoSuchElementException异常处理的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: web----epoll实现原理
- 下一篇: NO.1 python_人工智能_学习路