安装selenium

来源:互联网 发布:网络文化节logo 编辑:程序博客网 时间:2024/06/04 00:41

1、下载Python2.7版本,默认运行安装即可;  

 2、安装完成之后,设置Python环境变量C:\Python27(操作步骤: 电脑->属性->高级->环境变量->系统变量中的PATH为:变量值: ;C:\Python27 )

  3、在python的官方网站上可以找到SetupTools的下载,解压安装安装即可; 

 4、当安装SetupTools之后,就可以在python安装目录下看到Script目录,  

5、同样在变量中加入 path:C:\Python27\Scripts, 

 6、打开cmd命令行,将目录切换到C:\Python27\Scripts下,输入命令“easy_install pip“安装pip;

  7、安装成功pip之后,执行pip install -U selenium 进行下载安装最新selenium的版本。


下载的 selenium-3.0.2-py2.py3-none-any.whl 放到了D盘下pip install d:\selenium  失败(py3) C:\Users\Administrator>pip install d:\seleniumInvalid requirement: 'd:\selenium'It looks like a path. Does it exist ?如下命令即可就安装完成C:\Users\Administrator>pip install seleniumCollecting selenium  Downloading selenium-3.0.2-py2.py3-none-any.whl (915kB)    100% |████████████████████████████████| 921kB 204kB/sInstalling collected packages: seleniumSuccessfully installed selenium-3.0.2


自己安装在anaconda2和3的目录下都安装了 
C:\Users\Administrator>activate py3(py3) C:\Users\Administrator>pip install seleniumCollecting selenium  Using cached selenium-3.0.2-py2.py3-none-any.whlInstalling collected packages: seleniumSuccessfully installed selenium-3.0.2(py3) C:\Users\Administrator>python -m pip install --upgrade pipCollecting pip  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)    100% |████████████████████████████████| 1.3MB 177kB/sInstalling collected packages: pip  Found existing installation: pip 8.1.2    Uninstalling pip-8.1.2:      Successfully uninstalled pip-8.1.2Successfully installed pip-9.0.1

参考?
https://chromedriver.storage.googleapis.com/index.html?path=2.25/

参考: http://blog.csdn.net/tuconghuan/article/details/53413184

最近准备利用Python实现自动化chrome网页操作,这里将准备安装过程总结:
1、安装anaconda
      由于anaconda集成了python和集成开发环境spyder,安装anaconda很省事。
      下载地址:anaconda
      安装成功检验方式:
      (1)在cmd命令行输入python,可查看python版本,
      (2)cmd命令行输入pip list,可查看库列表
2、安装第三方库selenium
      cmd命令行下,输入pip install selenium
3、安装chrome浏览器
4、下载chromedriver.exe
      下载地址:chromedriver
      放到chrome安装目录下,并保证chrome安装目录在环境path中
5、使用chrome浏览器自动网页操作
      具体代码涉及知识点:selenium元素查找、元素属性、模拟鼠标和键盘操作等


参考:  http://blog.csdn.net/my2010sam/article/details/38582491
>>>安装Chrome driverchrome driver的下载地址:    https://chromedriver.storage.googleapis.com/2.10/chromedriver_win32.zip1. 下载并解压,你会得到一个chromedriver.exe文件2.将解压后的exe文件放到chrome的安装目录下...\Google\Chrome\Application\ (我的Chrome安装目录:C:\Program Files (x86)\Google\Chrome\Application )3.设置path环境变量,把chrome的安装目录添加至环境变量4.调用运行[python] view plain copy#coding:utf-8    from selenium import webdriver  import time  def main():      b=webdriver.Chrome()      b.get('http://www.baidu.com')      time.sleep(5)      b.quit()    if __name__ == '__main__':      main()  >>> 安装IE driver在新版本的webdriver中,只有安装了ie driver使用ie进行测试工作。ie driver的下载地址在这里,记得根据自己机器的操作系统版本来下载相应的driver。暂时还没尝试,应该和chrome的安装方式类似。 记得配置IE的保护模式如果要使用webdriver启动IE的话,那么就需要配置IE的保护模式了。把IE里的保护模式都选上或都勾掉就可以了。


0 0
原创粉丝点击