Robot Framework

来源:互联网 发布:linux查看进程被占用 编辑:程序博客网 时间:2024/05/17 03:53

RobotFramework是一个用关键字驱动的测试框架,常用于GUI的自动化测试中

 

1、环境搭建

--python

--setuptools

-- RobotFramework

--wxpython

--robotframework-ride

ride要求wx版本为2.8,若wxpython版本高于2.8,可修改rideide目录下的__init__文件,使其兼容3.0。

 

2ride

工程 -- 测试套件 -- 测试案例

-- 资源文件:用来存放用户自定义的关键字

-- 变量:${var}(单值变量)、@{var}(list类型变量)、%{var}(环境变量引用)

--字符串:1234abc${var}lgkf(嵌入变量直接合在一起写即可)

--关键字:每个关键字可以理解为一个函数

--循环:FOR

--判断:RunKeywordIf

 

3RF测试库

 

RF中的关键字

 

1)内置测试库

Evaluate:

Should:

Convertto

RunKeyword

 

Call Method  ·  Catenate  ·  Comment  ·  Convert To Binary  ·  Convert To Boolean  ·  Convert To Hex  ·  Convert To Integer  ·  Convert To Number  ·  Convert To Octal  ·  Convert To String  ·  Create List  ·  Evaluate ·  Exit For Loop  ·  Fail  ·  Fatal Error  ·  Get Count  ·  Get Length  ·  Get Library Instance  ·  Get Time ·  Get Variable Value  ·  Get Variables  ·  Import Library  ·  Import Resource  ·  Import Variables  ·  Keyword Should Exist  ·  Length Should Be  ·  Log  ·  Log Many  ·  Log Variables  ·  No Operation  ·  Regexp Escape  ·  Remove Tags  ·  Repeat Keyword  ·  Replace Variables  ·  Run Keyword  ·  Run Keyword And Continue On Failure  ·  Run Keyword And Expect Error  ·  Run Keyword And Ignore Error  ·  Run Keyword If  ·  Run Keyword If All Critical Tests Passed  ·  Run Keyword If All Tests Passed  ·  Run Keyword If Any Critical Tests Failed  ·  Run Keyword If Any Tests Failed  ·  Run Keyword If Test Failed  ·  Run Keyword If Test Passed  ·  Run Keyword If Timeout Occurred  ·  Run Keyword Unless  ·  Run Keywords  ·  Set Global Variable  ·  Set Library Search Order  ·  Set Log Level  ·  Set Suite Variable  ·  Set Tags  ·  Set Test Message  ·  Set Test Variable  ·  Set Variable  ·  Set Variable If  ·  Should Be Empty  ·  Should Be Equal  ·  Should Be Equal As Integers  ·  Should Be Equal As Numbers  ·  Should Be Equal As Strings  ·  Should Be True  ·  Should Contain  ·  Should Contain X Times  ·  Should End With  ·  Should Match  ·  Should Match Regexp  ·  Should Not Be Empty  ·  Should Not Be Equal  ·  Should Not Be Equal As Integers  ·  Should Not Be Equal As Numbers  ·  Should Not Be Equal As Strings  ·  Should Not Be True  ·  Should Not Contain  ·  Should Not End With  ·  Should Not Match  ·  Should Not Match Regexp  ·  Should Not Start With  ·  Should Start With  ·  Sleep  ·  Variable Should Exist  ·  Variable Should Not Exist  ·  Wait Until Keyword Succeeds

 

2)自定义测试库

 

4Web自动化测试

 

RobotFramework框架下进行web自动化测试可使用Selenium2Library库来进行

 

Selenium2Library中常用的关键字分类:

--browserManagement

OpenBrowser

Close Browser

Go to

Go back

 

--Cookie

addcookie

deletecookie

deleteall cookies

getcookies

getcookie value

 

--Elements

控件操作相关的关键字

 

--JavaScript

executeJavaScript

executeasync JavaScript

 

--sceenshot

capturepage screenshot

 

--waiting

wait forcondition

waituntil page contains

waituntil page contains element

 

5、C/S自动化测试

 

RobotFramework框架下进行C/S自动化测试可使用AutoItLibrary库来进行

 

关键字:

--Window操作

--Control操作

--Mouse操作

--Process操作

--Run操作

--Reg操作

 

6、数据库自动化测试

 

RobotFramework框架下进行数据库自动化测试可使用DatabaseLibrary库来进行

 

关键字:

--connect to database:链接数据库,标准链接

-- connect to database using custom params:使用自定义参数链接数据库

-- disconnect from database:断开数据库

-- query:查询数据库,可用list变量接收返回结果

-- row count:查询sql语句的结果条目数,这里用query也能完成

-- execute sql script:执行sql文件,sql文件中是sql的脚本语句

-- execute sql string:执行sql脚本

 

7、接口自动化测试

 

RobotFramework框架下进行接口自动化测试可使用requestsLibrary库来进行

 

关键字:

--Create Session:创建一个session,连接某个服务器

-- Create Ntlm Session:创建一个session,并加上域、用户名、密码用于NTLM认证

-- Get Request:通过Get方式发起请求

-- Post Request:通过Post方式发起请求

-- Head Request:发送一个HEAD请求

-- To Json:将文本转换成json对象

 

8、移动自动化测试

 

RobotFramework框架下进行移动自动化测试可使用appiumLibrary库来进行

0 0