我想关闭这个弹出窗口,但我不能,
我曾尝试使用 find.element.by.xpath()
我猜有所有不同的可能性,
尝试使用 switch_to _alert().dismiss()
但似乎没有任何帮助
任何帮助深表感谢,
谢谢
答案 0 :(得分:1)
似乎不是警报。它只是网页上的另一个元素。
Induce WebDriverWait
() 并等待 element_to_be_clickable
() 和后面的 css 选择器
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div#dismiss-button"))).click()
您需要导入以下库。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
注意:如果出现超时错误,请检查该元素是否在 iframe
下。如果是这样,您需要切换到 iframe
以交互按钮元素。