[博客迁移][爬虫] AttributeError: 'WebDriver' object has no attribute 'switchTo' 解决方法

8,826 阅读1分钟

from AttributeError: 'WebDriver' object has no attribute 'switchTo' 解决方法


使用selenium框架进行chrome模拟操作时,可能会需要点击弹出的alert。

在网上搜到的代码是driver.switchTo().alert().accept(),运行报错

解决方法:

改为chrome.switch_to.alert.accept()