Python get pop-up box and click to confirm the error report UnexpectedAlertPresentException

alert = self.browser.switch_to_alert ();
sleep (2);
alert.accept ();
Click OK using this get pop-up box, sometimes it will report that UnexpectedAlertPresentException, sometimes does not have it, and I don"t know why.

Mar.05,2021
Menu