1.升级pip
windows CMD
D:Program FilesPython34Scripts>pip install --upgrade pip 升级失败,提示尝试替换自身失败
改用
D:Program FilesPython34Scripts>easy_install pip 升级到最新版本
Python环境
python -m pip install -U pip
2.安装Selenium
windows CMD
D:Program FilesPython34Scripts>pip install selenium
输出:
Requirement already satisfied (use --upgrade to upgrade): selenium in d:program
filespython34libsite-packages
VS建立项目测试:
# -*- coding: utf_8 -*-
import os
from selenium import webdriver
iedriver = "C:Program FilesInternet ExplorerIEDriverServer.exe"
os.environ["webdriver.ie.driver"] = iedriver
driver = webdriver.Ie(iedriver)
driver.get("http://www.baidu.com")
print(driver.title)
driver.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
修改注册表 HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settingsones
修改1、2、3、4文件中2500属性值 修改成相同属性值、如1-2文件中是3,3-4文件中是0,修改3、4中2500属性值为3,重新运行脚本即可打开浏览器
参考http://www.cnblogs.com/cllovewxq/p/5420546.html