Robot Framework测试框架安装和应用实践

Robot Framework安装:
1,Python2.7以上版本—这里用的是 Python3.8


2,pip 和 setuptools (Python 的套件管理程式,最新版的Python 2.7.13已包含)

3,Robot Framework (此工具本身)

4,wxPython (Python 非常有名的一个GUI 库,支撑Ride的运行库)

5,robotframework-ride

6,selenium2library (selenium2测试库,基于webdriver驱动)

7,geckodriver, chromedriver 和 IEDriverServer (浏览器驱动,据说45以上的版本Firefox驱动也不再是默认包含)

8,AutoItLibrary (autoit库包,用于进行Windows GUI的自动化操作)

9,pywin32 (AutoIt的运行环境)

10,autoit (autoit客户端程序,实际运用中,必须装了autoit才能用AutoItLibrary )
11, robotframework-sshlibrary安装命令:pip install robotframework-sshlibrary

pip无法连接或连接超时解决方案
设置超时时间:pip --default-timeout=600 install  XXX
或者制定国内镜像站
设置超时时间:pip --default-timeout=600 install  XXX -i http://pypi.douban.com/simple --trusted-host 
mirrors:
http://mirrors.aliyun.com/pypi/simple/
https://mirrors.bfsu.edu.cn/pypi/web/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
https://pypi.mirrors.ustc.edu.cn/simple/

example:
[root@centos script]# cat test.robot

*** Settings ***
Documentation     A test suite with a single test for valid login.
...
...               This test has a workflow that is created using keywords in
...               the imported resource file.

#Resource          resource.robot
Library     OperatingSystem

#Suite Setup       Open Browser To Login Page
#Suite Teardown    Close Browser
#Test Setup        Go To Login Page
#Test Teardown     Close Browser
#Test Template     Login With Invalid Credentials Should Fail

#Settings

*** Variables ***
${MESSAGE}  Hello,world!

*** Keywords ***
My Keyword
    [Arguments]  ${path}
    DIRECTORY SHOULD EXIST  ${path}

*** Test Cases ***
Testcase_001
    [Documentation]     Example test
    log  ${message}
    log to console    ${message}
    Should match Regexp    ${message}    worl

Testcase_002
    should be equal     ${message}  Hello,world!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
RobotFramework中 中SSHLibrary学习与总结 学习与总结 ⼀、安装SSHLibrary ⼆.关键字 1.与连接相关的 Open Connection Get Connection Get Connections Switch Connection Close Connection Close All Connections Login Login With Public Key Set Client Configuration Set Default Configuration Enable Ssh Logging 2.与⽂件/⽬录相关的 2.1 File Should Exist , File Should Not Exist, Directory Should Exist , Directory Should Not Exist 2.2 List Directory, List Files In Directory , List Directories In Directory 2.3 Put Directory ,Get Directory,Put File,Get File 3.与读写执⾏相关的 Write Write Bare Write Until Expected Output Read Read Until Read Until Prompt Read Until Regexp Execute Command Start Command Read Command Output ⼀、安装 ⼀、安装SSHLibrary 安装命令:pip install robotframework-sshlibrary ⼆ ⼆.关键字 关键字 1.与连接相关的 与连接相关的 Open Connection ⽤法: [ host " alias=None " port=22 " timeout=None " newline=None " prompt=None " term_type=None " width=None " height=None " path_separator=None " encoding=None ] 默认设置:timeout=3 seconds, newline=LF, prompt=None, loglevel=INFO, term_type=vt100, width=80,height=24, path_separator=/, encoding=UTF-8.其 中,newline=LF/CRLF(\n,\r\n) 更改默认设置: 1.导⼊库时: Library SSHLibrary 10 seconds prompt=$ 2.使⽤ Set Client Configuration/Set Default Configuration 3.调⽤Open Connection时: 结果: ${con1} =index=1 path_separator=/ prompt=# width=80 newline= height=24 encoding=UTF-8 alias=backend host=10.69.140.112 timeout=3 seconds term_type=vt100 port=2222 Get Connection ⽤法:[ index_or_alias=None " index=False " host=False " alias=False " port=False " timeout=False " newline=False " prompt=False " term_type=False " width=False " height=False " encoding=False ] 1.获取connection的信息,如果调⽤时没有加 index_or_alias,返回当前的conection信息。 2.获取connection的特定属性信息,后边加属性名=⾮false/False字符串。 结果: ${con1} =index=1 path_separator=/ prompt=# width=80 newline= height=24 encoding=UTF-8 alias=backend host=10.69.140.112 timeout=3 seconds term_type=vt100 port=2222 ${con2} = (2222, 3.0) Get Connections ⽤法:没有输⼊值,获取所有打开的connection的信息 结果: ${con1} = index=1 path_separator=/ prompt=$ width
Robotframework】列表List的常⽤操作 1. Create List # 新建⼀个list变量 @{list} create list aa bb # 为list追加数据 同Append To List @{list} create list @{list} cc 打印list时,使⽤log many:log many @{list} 若⽤log打印,则写成:log ${list} 打印string时,使⽤log: log ${string} 以下关于list的操作类关键字,是在collections库中的,使⽤前,需要引⼊该库 2 Append To List-为list追加数据 ⽐如create list中的⽰例,也可以使⽤: # 新建⼀个list变量 @{list} create list aa bb # 为list追加数据 同Append To List Append To List @{list} cc 3 Get Slice From List-切⽚ 可以获取list的某⼀段⼦list,从两端截取或从中间截取 ⽰例: #list的下标从0开始 @{list} Create List lilei hanmeimei liming liliang liming # 获取从index=1及之后的数据 ${fromlist} Get Slice From List ${list} 1 # 获取从index=1~2的数据,不包括第3个 ${fromtolist} Get Slice From List ${list} 1 3 4 Remove Duplicates-去重 ⽰例: @{list} Create List lilei hanmeimei liming liliang liming # list去重并检查不包含重复数据 ${listnew} Remove Duplicates ${list} List Should Not Contain Duplicates ${listnew} 在log中会打印出来去掉了⼏个重复数据: 20201015 18:46:47.647 : INFO : 1 duplicate removed. 5 List Should Contain Sub List-包含⼦list ⽰例: @{list} Create List lilei hanmeimei liming liliang liming @{sublist} Create List lilei hanmeimei # 是否包含⼦list List Should Contain Sub List ${list} ${sublist} 6 List Should Not Contain Duplicates-判断不存在重复 ⽰例,去重后,list就不存在重复数据了,最后⼀⾏可执⾏通过: @{list} Create List lilei hanmeimei liming liliang liming ${listnew} Remove Duplicates ${list} List Should Not Contain Duplicates ${listnew} 7 Lists Should Be Equal-判断list相等 注意:@{list}是robot提供的语法,python并没有@{},只有${},所以要⽐较两个@{list},需要把@{list},直接写成英⽂dollar ${list}进 ⾏对⽐ ⽰例: @{list} Create List lilei hanmeimei liming liliang liming Remove From List ${list} 0 @{list1} Create List hanmeimei liming liliang liming Lists Should Be Equal ${list} ${list1} Remove Values From List ${list} liming @{list2} Create List hanmeimei liliang Lists Should Be Equal ${list} ${list2} 如果list转换成了string,也可以使⽤should be equal来做相等判断 8 Remove (Values) From List-删除list中某个值 Remove From List:按照index删除,⼀次删除1个 Remove Values From List:按照value值删除,⼀次可删除多个 ⽰例如2.6 9 Sort List–升序排序 对list做升序排序,⽰例: @{list} Create L
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值