原因:进入源码可以看到,alert_is_present是一个class类,因此调用的时候要加上括号alert_is_present()
解决方法:
def accept_alert(self): """确认弹框""" try: WebDriverWait(self.driver, self.max_wait_time).until(EC.alert_is_present()) alert = self.driver.switch_to.alert alert.accept() except Exception as e: raise e
selenium——关于alert弹框踩过的坑:TypeError: 'Alert' object is not callable
原文:https://www.cnblogs.com/erchun/p/12889923.html