import time from selenium import webdriver driver = webdriver.Chrome() driver.get("某个会有弹窗的网址") # 关于alert弹框的切换 alert = driver.switch_to.alert # 点击确认 alert.accept() # 点击取消 alert.dismiss() # 输入内容 alert.send_keys("666888") alert.accept() time.sleep(10) driver.quit()