python - 警报弹出异常处理 Python Selenium
问题描述
我正在尝试进行警报异常处理,我尝试了一些选项,但我似乎无法让脚本尝试异常,它只是出错了。
#Add Alert Bypass
try:
driver.switch_to.default_content()
except NoAlertPresentException:
print('Alert Popup')
alert = driver.switch_to.alert()
alert.dismiss()
错误信息:
Message: unexpected alert open: {Alert text : ...}
解决方案
看起来您使用了错误selenium.common.exceptions
根据错误消息,它看起来像是一个意外警报。我会尝试使用UnexpectedAlertPresentException
而不是NoAlertPresentException
推荐阅读
- angular - Angular httpclient.post 没有创建正确的正文
- html - 为什么我的 :active 选择器在缩放转换时会失去其点击事件状态?
- reactjs - 使用 Link 模块的 Next.js 页面未通过 CSS 导入加载文件
- encoding - HEVC 中 last_sig_coeff_x,y_prefix 标志有多少个上下文?
- jquery - 将同一张表中另一个TD中的TD内容移动
- amazon-web-services - 如何在 RDS MySQL 数据库之前保留 Amazon ElastiCahe Memcached/Redis 并使用 ElastiCache 缓存内容?
- python - 如何在 Atom 中安装 Swampy?
- android - 在 AsyncTask 的 onPostExecute 之后,无法按意图更新 RecyclerView
- opencl - OpenCL 图像对象和边界检查
- vba - 我可以使用 .getpoint 选择圆锥顶部的位置吗