关于弹出框点击确认不执行的问题
#切换至弹窗并点击确定
def accept_alert(self):
try:
WebDriverWait(self.driver, 20).until(EC.alert_is_present())
alert = self.driver.switch_to.alert
alert.accept()
except BaseException:
logger.error('弹出框失败.')
def receive_all_docs(self):
self.click(*self.chkall_checkbox)
self.click(*self.response_btn)
self.accept_alert()
结果弹出框不出现,错误提示
raise exception_class(message, screen, stacktrace, alert_text) selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: ……? Message: Modal dialog present with text: …… ?
关于 LearnKu
There must be somethig you didn't trace why it happened, and that's what you should provide for question here. If not, how people can help you to find the solution.
You can see following codes work ...
Python selenium —— 一定要会用selenium的等待,三种等待方式解读