【python】selenium+python自动化测试环境搭建

参考资料:

http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html

http://www.easonhan.info/python/2013/05/07/setup-env/

 

 

安装selenium

1、通过pip 安装

C:\Users\lauren>python -m pip install selenium

2、通过下载包安装

直接下载selenium包:

https://pypi.python.org/pypi/selenium

解压,cmd进入目录:

C:\selenium-3.0.1>python setup.py install

安装完成后,进入python安装目录下的Scripts目录,在命令行中运行pip.exe install selenium -i http://b.pypi.python.org/simple,注意-i选项是指定了index,也就是pypi的镜像源,至于为什么这样做,感觉应该是为了同步镜像源(有待确认)。

 

安装chromedriver

chromedriver.exe我是在下面的地址下载的:

http://vdisk.weibo.com/s/GLALSq503hN1?category_id=0&parents_ref=GLALSq503hML

下载解压,会得到一个chromedriver.exe文件。将其放到chrome的安装目录下...\Google\Chrome\Application\ , 然后设置path环境变量,把chrome的安装目录(我的:C:\Program Files (x86)\Google\Chrome\Application)加到环境变量里,然后再调用运行chromedriver.exe,会出现如下对话框,说明安装成功。

***注:Chrome version must be >= 27.0.1453.0\n  (Driver info: chromedriver=2.0,platform=Windows NT 5.1 SP3 x86) (我使用的是ChromeStandalone_51.0.2704.106_Setup.exe)

在pycharm里运行如下脚本,可以进一步验证selenium和chromedriver是否可以正常调用:

 

 


 

posted @ 2016-10-25 18:49  Lauren  阅读(678)  评论(0编辑  收藏  举报