RobotFramework-InterfaceLibrary is an Interface library for RobotFramework
It includes post, get, delete, put method to send http requests,and also use MySql
datebase to verify the Correctness of response datas.
It depends on requests library,and support Python 2.x and MySql database only.
mysql-connector-python should be installed manually first:
pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df
The main benefit of using pip is that it installs all
depended libraries automatically.
Another nice feature is easy to manipulate:
pip install robotframework-interfacelibrary # install
pip install -U robotframework-interfacelibrary # to stable
pip install -U robotframework-interfacelibrary --pre # to lastest
pip uninstall robotframework-interfacelibrary # uninstall
Here is a sample test case.
| Settings | ||||||
| Library | String | |||||
| Library | Collections | |||||
| Library | InterfaceLibrary | |||||
| Test Cases | ||||||
| Post Requests | ||||||
| Create Session | &{enviro}[host] | &{enviro}[port] | alise | |||
| Conncet To Datebase | ${host} | ${user} | ${password} | ${database} | ${port} | |
| ${res} | Post Request | /activity/addActivity | {'activityName':'${activityName}'} | None | ||
| Check Code | ${resp} | 200 | ||||
| ${res} | Post File Request | /cgi-bin/file/upload | {'file':open('logo.jpg','rb')} | {'type':'jpg'} | ||
| Datebase requests | ${list} | Mysql Select | SELECT name, age FROM tab WHERE ID = ${id} | |||
| ${name} | Get From List | 0 | ||||
| ${age} | Get From List | 1 | ||||
| Should be equal | ${activityName} | ${name} | ||||
| Delete Rows From Table | id=${id} | comapp_tab | #condition and table name | |||
| Check If Not Exist In Datebase | SELECT * FROM comapp_tab WHERE id=${id} | |||||
| Check if Exist In Datebase | SELECT name,company_id FROM staff_tab WHERE id=${id} |
-
Web端:
1.通过Cookie登录访问:
设置环境变量keyword:
create session
connect to database
post/get request 登录接口
2.通过特殊的方式登录比如传入token key id等 可调用encrypt post 将字段放入headers中来实现登录 -
Mobile端: 包括PC,Mobile客户端,通过Proxy访问需要加密,根据项目需求可扩展测试库增加相应的加密算法关键字,
定制request headers,加密请求体body,再调用encrypt post关键字发送加密http 请求。
Wu Qi
Wei Yating
Robot Framework: http://robotframework.org
requests: http://docs.python-requests.org/en/master
mysql: https://github.com/sanpingz/mysql-connector