Python-selenium:Protected Mode settings are not the same for all zones.
2016-08-18 15:49
441 查看
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">编码环境:</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> gvim 7.4</span>
运行环境:
win7-32(en)powershell
Python 2.7.11
代码:
# -*-* coding: utf-8 -*- from selenium import webdriver from time import sleep # driver=webdriver.Chrome() # driver=webdriver.Firefox() def login163(): url = 'http://mail.163.com/' user = 'user' pwd = 'pwd' browser = webdriver.Ie() browser.get(url) sleep(20) frame = browser.find_element_by_id("x-URS-iframe") browser.switch_to_frame(frame) browser.find_element_by_name( "email" ).clear() browser.find_element_by_name( "email" ).send_keys( user ) browser.find_element_by_name( "password" ).send_keys( pwd ) browser.find_element_by_id( "dologin" ).click() browser.switch_to_default_content() return browser if __name__ == '__main__': browser = login163() sleep(30) browser.quit()
运行后错误提示信息:
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/受信任的站定/受限制的站点中的启用保护模式全部去掉勾,或者全部勾上
方法二
在生成webdriver对象之前,修改浏览器配置信息,如下:
#coding=utf-8 from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings'] = True dr = webdriver.Ie() dr.get("http://www.baidu.com") ... dr.quit()
相关文章推荐
- 解决selenium 启动ie浏览器报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones
- webdriver 实例 IE8报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the
- Kettle解析JSON错误,We MUST have the same number of values for all paths,We can not find and data with path [$.
- Chapter 12-Not All Materials Are the Same
- android studio运行时提示All packages are not available for download! the following package are not availa
- WCF : 修复 Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service 问题
- Create a program the checks all the links in your web page whether they are active or not.
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- SQL SERVER2008 EXPRESS setup -- the specified credentials for the sql server service are not valid
- ACM ICPC 2013-2014 H. Those are not the droids you're looking for(二分匹配-Dinic)
- Ural 1997-Those are not the droids you're looking for 二分图匹配
- 关于The GPG keys listed for the "***" repository are already installed but they are not corret
- org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or br
- PL/SQL and Python scripts for the same function
- Compound class names are not supported. Consider searching for one class name and filtering the results
- Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to us
- Fuel for openstack:untagged networks can not be assigned to the same interface
- dbca silent responseFile Not all required options provided for the command "createDatabase".Please r
- Example code for using the Selenium 2 Python bindings. — Gist
- [iphone]Pattern colors are not supported by the iPhone SDK for iPhone OS versions prior to 3.0 解决