selenium webdriver启动IE浏览器失败的解决办法

通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones.
解决办法:修改浏览器安全设置---工具-Internet选项-安全-(Internet/本地Internet/受信任的站定/受限制的站点)启用保护模式全部勾选或全部去掉勾选。

 

然后运行脚本出现如下问题:

selenium.common.exceptions.WebDriverException: Message: Failed to navigate to http://www.baidu.com. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed.

解决办法:在生成webdriver对象之前,用脚本修改浏览器配置:

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
DesiredCapabilities.INTERNETEXPLORER["ignoreProtectedModeSettings"] = True

 

posted on 2017-01-09 10:16  荒荒9468  阅读(1539)  评论(0编辑  收藏  举报