Javascript 使用selenium在chrome中处理警报时出现意外的AlertPresentException

Javascript 使用selenium在chrome中处理警报时出现意外的AlertPresentException,javascript,python,google-chrome,selenium,selenium-chromedriver,Javascript,Python,Google Chrome,Selenium,Selenium Chromedriver,ChromeDriver版本=2.24/2.2Chrome浏览器版本=52 硒=2.53.6 Python=2.7 我的代码是 browser.find_element_by_id("save").click() browser.switch_to_alert().accept() 根据不同论坛和帖子的建议,我尝试将sleep,trycatch块,WebDriverWait用于提示,但都没有效果 我还注意到我的代码甚至没有进入浏览器。切换到警报().accept(),单击()操作本身抛出错误

ChromeDriver版本=2.24/2.2
Chrome浏览器版本=52
硒=2.53.6
Python=2.7

我的代码是

browser.find_element_by_id("save").click()
browser.switch_to_alert().accept()
根据不同论坛和帖子的建议,我尝试将
sleep
try
catch
块,
WebDriverWait
用于提示,但都没有效果

我还注意到我的代码甚至没有进入浏览器。切换到警报().accept(),
单击()
操作本身抛出错误

selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message: unexpected alert open: {Alert text : Are you sure you want to save changes?}

您确定它是一个警报而不是一个常规弹出窗口吗?是的,它是一个警报您使用的浏览器是什么??你的selenium版本是什么?这是我问题中提到的第一件事。你确定它是一个警报而不是一个常规的弹出窗口吗?是的,它是一个警报你在使用什么浏览器??你的硒版本是什么?这是我问题中提到的第一件事。