Robot Framework - 建立本地测试环境

注意:本文内容是以“在Window7系统中安装本地RobotFrmamework自动化测试环境”为例。

Robot Framework简介

Robot Framework documentation: http://robotframework.org/robotframework/
  • Robot Framework 是一款基于 Python 的功能自动化测试框架;
  • 具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型的客户端或者接口,可以进行分布式测试执行;
  • 可用于验收测试和验收测试驱动开发(ATDD);

安装RIDE

安装顺序:Python ---> setuptools & pip ---> Robot Framewok ---> wxPython(v2.8.12.1) ---> RIDE

1-安装Python并设置环境变量

>python --version
Python 2.7.12

>
>pip list
pip (8.1.1)
setuptools (20.10.1)

环境变量 PYTHONPATHC:\Python27\;C:\Python27\Lib\site-packages;C:\Python27\Scripts

建议执行“python -m pip install --upgrade pip ”升级pip。

2-安装robotframework

根据需要搜索并下载对应源码的压缩包(.tar.gz或.zip),解压后,切换到对应目录,运行:python setup.py install即可安装.

>pybot --version
Robot Framework 3.0 (Python 2.7.12 on win32)

3-安装wxPython

wxPython2.8-win64-unicode-2.8.12.1-py27.exe
 
4-安装robotframework-ride
>ride.py  # 启动RIDE

5-确认已完成所有安装

>pip list
pip (8.1.2)
robotframework (3.0)
robotframework-ride (1.5.2.1)
setuptools (20.10.1)
>

安装SSH访问库

安装顺序:

  1. PyCrypto
  2. ecdsa 
  3. paramiko
  4. robotframework-sshlibrary

确认所有安装包

>pip list
ecdsa (0.13)
paramiko (1.14.0)
pip (8.1.2)
pycrypto (2.6)
robotframework (3.0)
robotframework-ride (1.5.2.1)
robotframework-sshlibrary (2.1.2)
setuptools (20.10.1)
>

验证

>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import SSHLibrary
>>>
>>> ssh = SSHLibrary.SSHLibrary()
>>> ssh.open_connection("10.92.111.76", "22")
1
>>> ssh.login("root", "arthur")
u'Last login: Wed Aug 17 12:32:25 2016 from 10.141.98.107\r\r\n[root@clab395node01 ~]# '
>>> print ssh.execute_command("whoami")
root
>>>

安装Oracle

1 - Oracle Instant Client

Oracle Instant Client provides Oracle access and allows you to run your applications without installing the standard Oracle client.  

Since Oracle Instant Client is composed of basic instant client  and the sdk instant client ,   thus two of them should be installed.

Unzip the packages(both instantclient-basic and instantclient-sdk) into a single directory such as "instantclient", in this instruction, the Oracle Instant Client's folder structure looks like:

 

To set environment variable, open environment variables setting, 

new a system variable named ORACLE_HOME, set its value with the Oracle  Instant Client installation path and  append ORACLE_HOME to path. See:

C:\Users\guowli>set ORACLE_HOME
ORACLE_HOME=C:\instantclient

C:\Users\guowli>
C:\Users\guowli>set path
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\RSA SecurID Token Common;C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\
Program Files (x86)\Sennheiser\SoftphoneSDK\;C:\Program Files (x86)\SafeCom\SafeComPrintClient;C:\Program Files\Tortoise
SVN\bin;C:\Python27;C:\Python27\Scripts;C:\Python27\Lib\site-packages;C:\Program Files\Java\jdk1.8.0_101\bin;C:\Program
Files\Java\jdk1.8.0_101\jre\bin;C:\instantclient
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

C:\Users\guowli>

2 - cx_Oracle

cx_Oracle is a Python extension module that allows access to Oracle databases and conforms to the Python database API specification.

 

3 - SQLAlchemy

SQLAlchemy is Python library that allows database connections directly from Python code, helps in handling results and also allows using Python's/SQLAlchemys's own exception handling. It could be compared in JAVA's jdbc library.

 确认所有安装包:

>pip list
cx-Oracle (5.1.2)
ecdsa (0.13)
paramiko (1.14.0)
pip (8.1.2)
pycrypto (2.6)
robotframework (3.0)
robotframework-ride (1.5.2.1)
robotframework-sshlibrary (2.1.2)
setuptools (20.10.1)
sqlalchemy (0.5.6)
>

验证

>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sqlalchemy
>>>
>>> host="10.92.111.76"
>>> port="1521"
>>> database="oss"
>>>
>>> connect_str = "oracle://omc:omc@" + str(host) + ":" + str(port) + "/" + str(database)
>>> engine = sqlalchemy.create_engine(connect_str, echo=False)
>>> c = engine.connect()
>>>
>>> result = c.execute("select owner,object_type from all_objects where object_name='FM_ALARM'").fetchall()
>>> 
>>> print result
[('PUBLIC', 'SYNONYM'), ('FM', 'VIEW')]
>>>

安装Selenium库

SeleniumLibrary is a  Robot Framework  test library that uses the popular  Selenium  web testing tool internally. 

It provides a powerful combination of simple test data syntax and support for  different browsers .  

Web testing TA cases requires SeleniumLibrary.

安装顺序:
  1. decorator
  2. Selenium
  3. robotframework-selenium2library
  4. IEDriverServer - (optional, for IE explorer)

确认所有安装包:

>pip list
cx-Oracle (5.1.2)
decorator (4.0.10)
ecdsa (0.13)
paramiko (1.14.0)
pip (8.1.2)
pycrypto (2.6)
robotframework (3.0)
robotframework-ride (1.5.2.1)
robotframework-selenium2library (1.7.4)
robotframework-sshlibrary (2.1.2)
selenium (2.53.2)
setuptools (20.10.1)
sqlalchemy (0.5.6)
>

猜你喜欢

转载自www.cnblogs.com/anliven/p/10010142.html