您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 其它办公文档 > 自动化测试框架安装及使用_Python
自动化测试框架的安装及使用Python+Nosetests+Webdriver+Eclipse目录自动化测试框架的安装及使用...............................................................................................1Python+Nosetests+Webdriver+Eclipse............................................................................11Python+Nosetests安装及配置............................................................................................21.1Python安装,以Windows为例...................................................................................21.2Python配置.....................................................................................................................21.3Python插件安装.............................................................................................................21.3.1setuptools安装........................................................................................................21.3.2pip安装(可选安装,如需在线安装selenium,则需要安装)........................31.3.3Nosetests安装.........................................................................................................31.3.4nose-testconfig安装................................................................................................31.3.5Unittest安装...........................................................................................................31.3.6requests安装...........................................................................................................41.3.7nose-selenium-0.07安装.........................................................................................41.3.8其他插件安装..........................................................................................................42Webdriver安装.....................................................................................................................42.1SeleniumWebdriver安装...............................................................................................42.2ChromeWebdriver安装.................................................................................................52.3IEWebdriver安装...........................................................................................................53Eclipse安装............................................................................................................................54框架使用说明........................................................................................................................74.1代码目录结构.................................................................................................................74.2使用说明........................................................................................................................81Python+Nosetests安装及配置下面所有安装均以离线安装为例(考虑公司网络问题),以下所有安装文件均可从“/hjqa/06技术分享/03Selenium/automation”中获取1.1Python安装,以Windows为例获取python-2.7.6.msi或者python-2.7.5.msi(/hjqa/06技术分享/03Selenium/SeleniumInstall/Python_pack)双击msi文件安装即可1.2Python配置右单击我的电脑(或计算机)-属性-高级-环境变量,在系统变量中找到PATH变量并编辑,添加Python安装路径到PATH变量(如:C:\Python27;)打开cmd窗口,运行python,显示如下图:1.3Python插件安装1.3.1setuptools安装目的:为安装其他插件做准备获取setuptools-3.3.zip,拷贝setuptoolszip包到C盘根目录解压,然后打开cmd窗口,切换路径至setuptools-3.3,运行pythonsetup.pyinstall,如下图所示安装完成后,可以在C:\Python27\Lib\site-packages下面找到setuptools文件夹及相关目录,和C:\Python27下面多了一个Scripts目录,并能在C:\Python27\Scripts下面看到ez_install.exe1.3.2pip安装(可选安装,如需在线安装selenium,则需要安装)目的:可以使用该命令在线安装插件获取pip-1.0.2.zip,拷贝pip-1.0.2zip包到C盘根目录解压,然后打开cmd窗口,切换路径至pip-1.0.2,运行pythonsetup.pyinstall安装完成后,可以在C:\Python27\Scripts下面找到pip.exe,和能在C:\Python27\Lib\site-packages下面找到pip-1.0.2-py2.7.egg文件夹安装成功后,可以删除解压后的目录1.3.3Nosetests安装目的:该插件属于我们的框架,为运行用例做准备获取nosetests文件,解压文件,将目录拷贝到C:\下面,打开cmd窗口,切换目录到C:\nose-1.3.1,运行pythonsetup.pyinstall安装完成后,可以在C:\Python27\Scripts下面看到nosetests.exe及相关文件为了确保nosetests对其他目录也有效,参看1.2添加C:\Python27\Scripts;到环境变量PATH里面。打开cmd窗口,输入nosetests,回车,没有错误显示表明安装成功1.3.4nose-testconfig安装目的:该插件用于框架里面的config文件导入,比如fromtestconfigimportconfig获取nose-testconfig-0.9.tar.gz文件,解压文件,将目录拷贝到C:\下面,打开cmd窗口,切换目录到C:\nose-testconfig-0.9,运行pythonsetup.pyinstall安装成功,如下图所示1.3.5Unittest安装目的:该插件其实Python有自带,这里是安装最新版本,为安装nose-selenium插件做准备获取unittest2-0.5.1.zip文件,解压文件,将目录拷贝到C:\下面,打开cmd窗口,切换目录到C:\unittest2-0.5.1,运行pythonsetup.pyinstall安装成功,如下图所示1.3.6requests安装目的:为安装nose-selenium插件做准备获取requests-2.2.1.tar.gz文件,解压文件,将目录拷贝到C:\下面,打开cmd窗口,切换目录到C:\requests-2.2.1,运行pythonsetup.pyinstall安装成功,如下图所示1.3.7nose-selenium-0.07安装目的:该插件用于nose框架和selenium结合使用获取nose-selenium-0.07.tar.gz文件,解压文件,将目录拷贝到C:\下面,打开cmd窗口,切换目录到C:\nose-selenium-0.07,运行pythonsetup.pyinstall安装1.3.8其他插件安装如需安装其他插件,请按上述方法操作Pydoc插件:用于连接SQLServer数据库Lxml插件(直接安装):用于解析XML文件2Webdriver安装2.1SeleniumWebdriver安装目的:WebDriver用于启动浏览器,模拟用户在浏览器上做操作获取selenium-2.40.0.zip文件,解压到C:\,打开cmd窗口,切换目录到C:\selenium-2.40.0,运行pythonsetup.pyinstall,安装成功后,输入python命令换行,进入python编辑模式,输入fromseleniumimportwebdriver,不报错,表明已经安装成功2.2ChromeWebdriver安装目的:用于Webdriver能够启动Chrome浏览器获取chromedriver.zip文件,解压文件,将chromedriver.exe拷贝到C:\Python27目录下,并添加C:\Users\Administrator\AppData\Local\Google\Chrome\Application\(chrome安装路径,这里是win7下的安装路径)到环境变量path2.3IEWebdriver安装目的:用于Webdriver能够启动IE浏览器获取IE
本文标题:自动化测试框架安装及使用_Python
链接地址:https://www.777doc.com/doc-4601097 .html