在 selenium 中处理 PopUp python

Handle PopUp in selenium python

我是硒的新手。我有一个弹出窗口。我附上了图片。我该如何处理。我试过了 switch_to_alert()

但是没有用。

这不是警报,因此应作为普通元素处理:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[text()="Process Payments"]'))).click()

确认

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[text()="Cancel"]'))).click()

拒绝