wxpython 跨平台的GUI工具集 下载
pip install wxpython
pip install robotframework
pip install robotframework-requests
pip install robotframework-ride #
不支持python3,如果使用python3安装会出错
pip install robotframework-databaselibrary  
pip install robotframework-mongodblibrary  
pip install robotframework-selenium2library 
pip install robotframework-seleniumlibrary  一个类似于IDE的工具,它是由Python开发的, 使用的wxPython GUI包,所以要安装RIDE要首先安装wxPython. 在window上安装wxPython很简单,从如下网站下载安装包安装就可以了。但是有一点需要注意的是,这里要使用32位的安装包,否则ride无法运行。
安装包下载地址:https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/
python PATH-TO-PYTHON\scripts\ride.py需要安装paramiko,而paramiko又依赖pycrypto,而这个pycrypto如果在windows安装有需要vs10以上的环境,但是幸运的是有已经编译好
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
里面选在对应python版本的pycrypto文件
我使用如下连接,对应python2.7 64bit版本
http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win-amd64-py2.7.exe
接着安装 pip install pamariko
安装完之后再python的命令行import paramiko报错
from bcrypt import _bcrypt
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
如果遇到这个问题,有可能你是基于python32bit升级到64bit原地升级导致,最稳健的方法是铲掉原来python目录,重新来,或者回退到32bit,这时之前选择wxpython以及pycrypto需要回退到32bit才可以,知道可以正常导入paramiko
如果不是windows系统,直接使用pip install pycrypto来安装即可
接着安装sshlibrary来支持远程命令控制
pip install robotframework-sshlibrarySSHLibrary官方api
    open connection    127.0.0.1
    ${output}    login    zhangsan    123456
    should contain    ${output}    Last login
    close connection    open connection    127.0.0.1
    ${output}    login with public key    root    id_rsa_train.txt
    should contain    ${output}    Last login
    close connection    open connection    127.0.0.1
    ${output}    login with public key    root    id_rsa_train.txt
    should contain    ${output}    Last login
    ${output}    execute command    grep -i -c " iNFO " /path-to-tomcat/catalina.out
    should be equal as integers    ${output}    657655
    close connectionRobot Framework Intellisens
robot my_tests.robot your_tests.robot
robot --name Example path/to/tests/pattern_*.robotwxPython not found.
You need to install wxPython 2.8.12.1 with unicode support to run RIDE.
wxPython 2.8.12.1 can be downloaded from http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/发现python27的版本是32,所以需要重新安装python64位版本
导入库, 标红表示库导入问题,其实就是import操作
注意导入库,除了在项目中有,还有testsuite也有
build in 库
系列课程
Scalar变量用 $ 作为标识符,List型变量用 @ 作为标识符
这里需要区分list变量跟不同变量,尤其是在for循环中
要这么写:dict['Title']
而不是:dict.Title
是你操作字典的方法错误了*** Settings ***
Library           requests
Library           RequestsLibrary
Library           Collections
Library           DatabaseLibrary
*** Test Cases ***
TestCGIHeartBeat
    [Documentation]    *Test CGI Heartbeat*
    [Tags]    post
    # Post请求
    ${header}    create dictionary    Content-Type    application/json
    create session    api    http://140.143.230.148:8080/cgi-bin/heartbeat    ${header}
    ${data}    create dictionary
    ${resp}    post request    api    ${data}
    log    ${resp.content}
    ${resp_data}    to json    ${resp.content}
    should be equal as integers    ${resp_data['code']}    0    ${header123}    create dictionary    Content-Type    application/json
    create session    api    http://140.143.230.148:8080/cgi-bin    headers=${header123}
    ${body_string}    set variable    { "bot_instance_id":"2420568e-47fa-11e8-a13a-6c92bf26dfc6", "query":"信用卡还款", "access_channel_code":"default", "max_res_num":100, "session_id":"stanley12", "extended_data": { "ip": "127.0.0.1", "age": 20, "name": "stanley" } }
    ${body}=    to json    ${body_string}
    ${resp}    post request    api    /search/out    data=${body}
    log    ${resp}
    ${resp_data}    to json    ${resp.content}
    should be equal as integers    ${resp_data['code']}    0需要安装pymongodb和 robotframework-mongodblibrary,rf导入库名字为MongoDBLibrary
    connect to mongodb    mongodb://tencent:tencent@127.0.0.1/bot_cloud_gray    ${mongo_db_port}
    ${count}    Get MongoDB Collection Count    bot_cloud_gray    bot_collection_
    log    ${count}
    ${allResult}    Retrieve Some Mongodb Records    bot_cloud_gray    bot_collection_    {"bot_id":46}
    log    ${allResult}
    disconnect from mongodb有两种方式,一种是使用convert to 系列函数
另一种如果用在断言中的,should be equal as 系列
    should be equal as integers     ${resp_data['code']}    0robot --include smoke --name Smoke_Tests path/to/tests.robot
robot --include smoke --name aibot_smoke -d ./aibot_test_result ./aibot/heartbeat.txt
http://mirrors.jenkins-ci.org/plugins/robot/
Error in test library 'pymysql': Creating keyword 'Connect' failed: Keyword with same name defined multiple times.原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。