问题:我无法单击“zgadzam sie”出现错误“selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{”方法“:“xpath”,“选择器”:”//span[@class='RveJvd snByac'和text()='Zgadzam się']”
问题:我如何处理? imageenglish image
from selenium import webdriver
import time
driver= webdriver.Chrome()
driver.implicitly_wait(3)
driver.get("https://www.google.com/")
driver.find_element_by_xpath("//span[@class='RveJvd snByac' and text()='Zgadzam się']").click()
driver.quit()
time.sleep(5)
尝试单击按钮后,您正在睡觉。你也会在睡觉前离开司机,这是另一个问题
考虑使用WebDriverWait().until()函数来确保加载元素,而不是依赖于任意的时间量:
出现此错误的原因是element is nested in an ^{} 。这可以通过等待iframe出现,然后等待加载按钮,最后单击按钮来解决:
尝试使用完整的xpath。您可以使用通常作为浏览器扩展下载的xpath工具找到它
相关问题 更多 >
编程相关推荐