[英]selenium.common.exceptions.NoSuchElementException
[英]selenium.common.exceptions.NoSuchElementException in Selenium
我正在尝试让 Selenium 自动在 Chrome 中打开网页。 这是我的代码...
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.python.org/")
element = driver.find_element_by_link_text("q")
print(element.click())
这是错误...
selenium.common.exceptions.NoSuchElementException
请帮忙。
我看到这里有两个问题:
element = driver.find_element_by_link_text("q")
之前添加延迟才能让页面加载。visibility_of_element_located
预期条件。q
的元素@Xman 的答案很简单。
selenium.common.exceptions.NoSuchElementException
错误意味着元素错误/不存在。
element = driver.find_element_by_link_text("q")
也许没有称为“q”的元素。 再次检查它,然后输入元素。 希望这有帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.