PySe-005-基础环境配置(Win7)

  之前的文章讲述了如何在 MacOX 下配置 Python + Selenium2 的 WebUI测试自动化环境配置,敬请参阅 PySe-001-基础环境配置(MacOX)

此文主要讲述如何配置 Python + Selenium2 在 Win7 下的 WebUI测试自动化环境配置,敬请各位小主参阅,若有不足之处,敬请大神指正,不胜感激!

 

一、安装 Python 2.7.10

进入 Python 的官方网站,下载 Win7 对应的 Python 版本,建议选择 2.7.X,当前最新版本为 2.7.10,下载并安装,我将其安装在了 C:\Python27 目录下。如下图所示:

安装完成后,查看安装目录 C:\Python27 是否添加到了环境变量中,若没有,则配置如下的环境变量:

PY_HOME=C:\Python27
path=%PY_HOME%;%path%

启动命令行控制台,输入 Python -V,查看安装版本,若出现以下信息,则说明 Python 安装成功。

Python 2.7.10

 

二、安装 setuptools 18.1

打开网址 https://pypi.python.org/pypi/setuptools/#downloads 下载 当前最新的 setuptools 18.1(内涵 ez_setup.py),如下图所示:

安装 setuptools 有以下两种方法:

  • 进入 ez_setup.py 所在的目录,执行命令 python ez_setup.py 进行安装 setuptools,此种情况下需要联网,若是出现如下提示信息,说明 setuptools 安装成功。
c:\Python27>python ez_setup.py
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-18.1.zip
Extracting in c:\users\aaron\appdata\local\temp\tmp62danx
Now working in c:\users\aaron\appdata\local\temp\tmp62danx\setuptools-18.1
Installing Setuptools
running install
running bdist_egg
running egg_info
writing requirements to setuptools.egg-info\requires.txt
writing setuptools.egg-info\PKG-INFO
writing top-level names to setuptools.egg-info\top_level.txt
writing dependency_links to setuptools.egg-info\dependency_links.txt
writing entry points to setuptools.egg-info\entry_points.txt
reading manifest file 'setuptools.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
copying easy_install.py -> build\lib
creating build\lib\pkg_resources
copying pkg_resources\__init__.py -> build\lib\pkg_resources
creating build\lib\setuptools
copying setuptools\archive_util.py -> build\lib\setuptools
copying setuptools\compat.py -> build\lib\setuptools
copying setuptools\depends.py -> build\lib\setuptools
copying setuptools\dist.py -> build\lib\setuptools
copying setuptools\extension.py -> build\lib\setuptools
copying setuptools\lib2to3_ex.py -> build\lib\setuptools
copying setuptools\msvc9_support.py -> build\lib\setuptools
copying setuptools\package_index.py -> build\lib\setuptools
copying setuptools\py26compat.py -> build\lib\setuptools
copying setuptools\py27compat.py -> build\lib\setuptools
copying setuptools\py31compat.py -> build\lib\setuptools
copying setuptools\sandbox.py -> build\lib\setuptools
copying setuptools\site-patch.py -> build\lib\setuptools
copying setuptools\ssl_support.py -> build\lib\setuptools
copying setuptools\unicode_utils.py -> build\lib\setuptools
copying setuptools\utils.py -> build\lib\setuptools
copying setuptools\version.py -> build\lib\setuptools
copying setuptools\windows_support.py -> build\lib\setuptools
copying setuptools\__init__.py -> build\lib\setuptools
creating build\lib\_markerlib
copying _markerlib\markers.py -> build\lib\_markerlib
copying _markerlib\__init__.py -> build\lib\_markerlib
creating build\lib\pkg_resources\_vendor
copying pkg_resources\_vendor\__init__.py -> build\lib\pkg_resources\_vendor
creating build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\specifiers.py -> build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\version.py -> build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\_compat.py -> build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\_structures.py -> build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\__about__.py -> build\lib\pkg_resources\_vendor\packaging
copying pkg_resources\_vendor\packaging\__init__.py -> build\lib\pkg_resources\_vendor\packaging
creating build\lib\setuptools\command
copying setuptools\command\alias.py -> build\lib\setuptools\command
copying setuptools\command\bdist_egg.py -> build\lib\setuptools\command
copying setuptools\command\bdist_rpm.py -> build\lib\setuptools\command
copying setuptools\command\bdist_wininst.py -> build\lib\setuptools\command
copying setuptools\command\build_ext.py -> build\lib\setuptools\command
copying setuptools\command\build_py.py -> build\lib\setuptools\command
copying setuptools\command\develop.py -> build\lib\setuptools\command
copying setuptools\command\easy_install.py -> build\lib\setuptools\command
copying setuptools\command\egg_info.py -> build\lib\setuptools\command
copying setuptools\command\install.py -> build\lib\setuptools\command
copying setuptools\command\install_egg_info.py -> build\lib\setuptools\command
copying setuptools\command\install_lib.py -> build\lib\setuptools\command
copying setuptools\command\install_scripts.py -> build\lib\setuptools\command
copying setuptools\command\register.py -> build\lib\setuptools\command
copying setuptools\command\rotate.py -> build\lib\setuptools\command
copying setuptools\command\saveopts.py -> build\lib\setuptools\command
copying setuptools\command\sdist.py -> build\lib\setuptools\command
copying setuptools\command\setopt.py -> build\lib\setuptools\command
copying setuptools\command\test.py -> build\lib\setuptools\command
copying setuptools\command\upload_docs.py -> build\lib\setuptools\command
copying setuptools\command\__init__.py -> build\lib\setuptools\command
copying setuptools\script (dev).tmpl -> build\lib\setuptools
copying setuptools\script.tmpl -> build\lib\setuptools
copying setuptools\cli-32.exe -> build\lib\setuptools
copying setuptools\cli-64.exe -> build\lib\setuptools
copying setuptools\cli-arm-32.exe -> build\lib\setuptools
copying setuptools\cli.exe -> build\lib\setuptools
copying setuptools\gui-32.exe -> build\lib\setuptools
copying setuptools\gui-64.exe -> build\lib\setuptools
copying setuptools\gui-arm-32.exe -> build\lib\setuptools
copying setuptools\gui.exe -> build\lib\setuptools
copying setuptools\command\launcher manifest.xml -> build\lib\setuptools\command
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
copying build\lib\easy_install.py -> build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\pkg_resources
creating build\bdist.win-amd64\egg\pkg_resources\_vendor
creating build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\specifiers.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\version.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\_compat.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\_structures.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\__about__.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\packaging\__init__.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging
copying build\lib\pkg_resources\_vendor\__init__.py -> build\bdist.win-amd64\egg\pkg_resources\_vendor
copying build\lib\pkg_resources\__init__.py -> build\bdist.win-amd64\egg\pkg_resources
creating build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\archive_util.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli-64.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli-arm-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli.exe -> build\bdist.win-amd64\egg\setuptools
creating build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\alias.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_egg.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_rpm.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_wininst.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\build_ext.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\build_py.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\develop.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\easy_install.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\egg_info.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_egg_info.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_lib.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_scripts.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\launcher manifest.xml -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\register.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\rotate.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\saveopts.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\sdist.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\setopt.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\test.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\upload_docs.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\__init__.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\compat.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\depends.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\dist.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\extension.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui-64.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui-arm-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\lib2to3_ex.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\msvc9_support.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\package_index.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\py26compat.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\py27compat.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\py31compat.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\sandbox.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\script (dev).tmpl -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\script.tmpl -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\site-patch.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\ssl_support.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\unicode_utils.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\utils.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\version.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\windows_support.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\__init__.py -> build\bdist.win-amd64\egg\setuptools
creating build\bdist.win-amd64\egg\_markerlib
copying build\lib\_markerlib\markers.py -> build\bdist.win-amd64\egg\_markerlib
copying build\lib\_markerlib\__init__.py -> build\bdist.win-amd64\egg\_markerlib
byte-compiling build\bdist.win-amd64\egg\easy_install.py to easy_install.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\specifiers.py to specifiers.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\version.py to version.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\_compat.py to _compat.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\_structures.py to _structures.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\__about__.py to __about__.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\packaging\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\_vendor\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\archive_util.py to archive_util.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\alias.py to alias.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py to bdist_egg.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_rpm.py to bdist_rpm.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_wininst.py to bdist_wininst.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\build_ext.py to build_ext.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\build_py.py to build_py.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\develop.py to develop.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\easy_install.py to easy_install.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\egg_info.py to egg_info.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install.py to install.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_egg_info.py to install_egg_info.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_lib.py to install_lib.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_scripts.py to install_scripts.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\register.py to register.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\rotate.py to rotate.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\saveopts.py to saveopts.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\sdist.py to sdist.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\setopt.py to setopt.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\test.py to test.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\upload_docs.py to upload_docs.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\compat.py to compat.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\depends.py to depends.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\dist.py to dist.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\extension.py to extension.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\lib2to3_ex.py to lib2to3_ex.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\msvc9_support.py to msvc9_support.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\package_index.py to package_index.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\py26compat.py to py26compat.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\py27compat.py to py27compat.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\py31compat.py to py31compat.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\sandbox.py to sandbox.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\site-patch.py to site-patch.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\ssl_support.py to ssl_support.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\unicode_utils.py to unicode_utils.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\utils.py to utils.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\version.py to version.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\windows_support.py to windows_support.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\_markerlib\markers.py to markers.pyc
byte-compiling build\bdist.win-amd64\egg\_markerlib\__init__.py to __init__.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\entry_points.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying setuptools.egg-info\zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
creating dist
creating 'dist\setuptools-18.1-py2.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing setuptools-18.1-py2.7.egg
Removing c:\python27\lib\site-packages\setuptools-18.1-py2.7.egg
Copying setuptools-18.1-py2.7.egg to c:\python27\lib\site-packages
setuptools 18.1 is already the active version in easy-install.pth
Installing easy_install-script.py script to c:\Python27\Scripts
Installing easy_install.exe script to c:\Python27\Scripts
Installing easy_install-2.7-script.py script to c:\Python27\Scripts
Installing easy_install-2.7.exe script to c:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-18.1-py2.7.egg
Processing dependencies for setuptools==18.1
Finished processing dependencies for setuptools==18.1
  • 将下载的 setuptools-18.1.zip 解压,进入解压目录,执行命令 python easy_install.py {setuptools 解压目录},若是出现如下提示信息,说明 setuptools 安装成功。
d:\DevTool\Python_Selenium\setuptools-18.1>python easy_install.py d:\DevTool\Python_Selenium\setuptools-18.1
Processing setuptools-18.1
Writing d:\DevTool\Python_Selenium\setuptools-18.1\setup.cfg
Running setup.py -q bdist_egg --dist-dir d:\DevTool\Python_Selenium\setuptools-18.1\egg-dist-tmp-1itpwz
Copying setuptools-18.1-py2.7.egg to c:\python27\lib\site-packages
Adding setuptools 18.1 to easy-install.pth file
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-18.1-py2.7.egg
Processing dependencies for setuptools==18.1
Finished processing dependencies for setuptools==18.1

 

三、安装 pip

安装 pip 也有两种方法:

第一种:打开网址: https://pypi.python.org/pypi/pip ,下载最新的 pip zip 文件,如下图所示,下载后解压至本地文件夹。

命令行进入对应的解压目录,执行命令 python setup.py install ,进行安装,出现如下信息时,说明成功安装了 pip

creating dist
creating 'dist\pip-7.1.0-py2.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing pip-7.1.0-py2.7.egg
creating c:\python27\lib\site-packages\pip-7.1.0-py2.7.egg
Extracting pip-7.1.0-py2.7.egg to c:\python27\lib\site-packages
Adding pip 7.1.0 to easy-install.pth file
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip2.7-script.py script to C:\Python27\Scripts
Installing pip2.7.exe script to C:\Python27\Scripts
Installing pip2-script.py script to C:\Python27\Scripts
Installing pip2.exe script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\pip-7.1.0-py2.7.egg
Processing dependencies for pip==7.1.0
Finished processing dependencies for pip==7.1.0

第二种,进入网址 : https://pip.pypa.io/en/stable/installing.html 下载 get-pip.py

下载后,命令行执行 python get-pip.py 安装 pip 即可,在此不再赘述!各位小主,自行探索啊 ^_^

(⊙o⊙)…悲剧,突然想起来,pip 自 python 2.7.9(含)和 Python 3.4(含)之后的版本中均已经包含了 pip,若是安装了此版本,则无需再次安装 pip。我这是。。。苍天啊!我这是傻了了么?只希望有安装低版本的小主们有帮助吧,嘿嘿!

 

四、安装 Selenium

进入命令行控制台,输入 python -m pip install -U selenium 安装 selenium for python,出现如下所示的信息,说明 selenium 安装成功。

 

至此,Win7 环境下 Python 2.7.10 + Selenium 2.47.1 WebUI自动化测试环境配置完成,恭喜各位小主了,还犹豫什么,赶紧开动您的手指吧,体验 Python + Selenium2 的神奇。

 

至此, PySe-005-基础环境配置(Win7) 顺利完结,希望此文能够给初学 Python + Selenium2 的您一份参考。

最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^

 

posted @ 2015-08-07 01:44  范丰平  Views(604)  Comments(2Edit  收藏  举报