[PYTHON] Press the OK cancel button on the Selenium Alert Confirm Box

Operate Alert Confirm Box in Selenium.

If you want to OK the following image.png image.png

from selenium import webdriver
from selenium.webdriver.common.alert import Alert

driver = webdriver.Chrome("driverPath")

#Press the OK button
Alert(driver).accept()

#Press the cancel button
Alert(driver).dismiss()

Environmental information

IDE image.png Python python-3.9.1

OS image.png

Recommended Posts

Press the OK cancel button on the Selenium Alert Confirm Box