【发布时间】:2019-03-26 17:17:33
【问题描述】:
如何在 Python 中使用 Selenium 绕过 NoSuchElementException 错误消息?我正在尝试从下拉菜单中选择报告类型,并在运行此代码后:
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome()
driver.get("https://examplehtml.com/gims/app/reports")
##Report type
driver.find_element_by_xpath('//*[@id="reportType"]').send_keys("Power
Report")
这会插入单词“Power Report”,但它不会像我手动选择报告类型那样选择和向前移动页面,我认为这是因为 NoSuchElementException 错误。为什么找不到元素以及如何解决此错误。我对 Selenium 相当陌生,所以任何建议都会有所帮助。
提前致谢!
【问题讨论】:
-
添加您要查找的元素的 html ?
-
不幸的是,我无法共享 html,因为该网站的访问受到限制@Navarasu
标签: java python selenium web-crawler nosuchelementexception