【发布时间】:2022-01-03 20:21:12
【问题描述】:
任何人都有一个解决方案,可以在网页中找到一个带有重叠弹出窗口的按钮,如下例所示:
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'./geckodriver')
driver.get("https://www.academics.de/")
#after waiting for a while the popup window comes up
driver.find_elements_by_xpath("//*[contains(text(), 'Zustimmen')]")
返回的列表为空。运行以下
driver.find_element_by_css_selector(".button-accept")
结果:
NoSuchElementException: Message: Unable to locate element: .button-accept
【问题讨论】:
标签: python selenium xpath iframe css-selectors