[英]selenium.common.exceptions.NoSuchElementException in Selenium
I am trying to make Selenium automatically open a webpage in Chrome.我正在尝试让 Selenium 自动在 Chrome 中打开网页。 This is my code...
这是我的代码...
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.python.org/")
element = driver.find_element_by_link_text("q")
print(element.click())
This is the error...这是错误...
selenium.common.exceptions.NoSuchElementException
Pls help.请帮忙。
I see there are 2 problems here:我看到这里有两个问题:
element = driver.find_element_by_link_text("q")
to let the page load.element = driver.find_element_by_link_text("q")
之前添加延迟才能让页面加载。visibility_of_element_located
expected condition for this.visibility_of_element_located
预期条件。q
thereq
的元素 The answer @Xman is simple. @Xman 的答案很简单。
selenium.common.exceptions.NoSuchElementException
error means that the element is wrong/doesn't exist.错误意味着元素错误/不存在。
element = driver.find_element_by_link_text("q")
maybe there is no element called "q".也许没有称为“q”的元素。 Do check it again and then enter the element.
再次检查它,然后输入元素。 Hope this helped:)
希望这有帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.