美文网首页
Python - no such alert

Python - no such alert

作者: robotframe | 来源:发表于2020-06-24 10:29 被阅读0次

python selenium中关闭网页弹出窗口用到了

driver.switch_to.alert.accept()

但是运行时报错:no such alert

解决方案:增加等待弹窗弹出时间,可以使用显式等待,当页面完全加载出弹出窗元素后再操作accept()

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.support.wait import WebDriverWait

WebDriverWait(driver,20,0.5).until(EC.alert_is_present())

actual_alert=driver.switch_to.alert.text

refer to 

https://blog.csdn.net/m0_38080393/article/details/96318466

相关文章

网友评论

      本文标题:Python - no such alert

      本文链接:https://www.haomeiwen.com/subject/zttrfktx.html