一、浏览器管理
Open Browser和Close Browser:打开和关闭浏览器
Close All Browsers:关闭所有浏览器
Select Window:选择窗口
Close Window:关闭窗口
Switch Browser:切换浏览器
Wait Until Keyword Succeeds:等待关键字执行成功
Select Frame:选择帧
Unselect Frame:直接跳出所有帧
二、cookie关键字
add cookie:添加cookie
delete cookie:删除cookie
delete all cookies:删除所有cookie
get cookies:获取所有cookie
get cookie value:获取cookie的值
三、DatabaseLibrary关键字
connect to database:连接数据库,标准连接
connect to database using custom params:使用自定义参数连接数据库
disconnect from database:断开数据库
query:查询数据库,可以用list变量接收返回结果
row count:查询sql语句的结果条数,用query也可以
execute sql script:执行sql文件
execute sql string:执行sql脚本,脚本用分号隔开,最后一个脚本不需要分号
四、接口自动化测试——requestsLibrary关键字
Create Session:创建一个session,连接某个服务器
Create Ntlm Session:创建一个session,连接某个服务器;加上了域、用户名、密码用于NTLM认证
Get Request:发起请求
Post Request:发起请求
Head Request:发送head请求
To Json:将文本转换成json对象
Copy Dictionary:复制字典
Set To Dictionary:添加元素到字典
Get Dictionary Keys:获取字典中的所有key值
Get Dictionary Items:获取字典中的所有元素
Get Dictionary Values:获取字典中的所有value值
Get From Dictionary:获取字典中指定key值
五、RF内置测试库
(1)BuiltIn库
类型转换
convert to integer:转换成整数
convert to number:转换成浮点数
convert to string:转换成字符串
convert to boolean:转换成布尔值
断言检验
should <not> be empty:是否为空
should <not> be true:是否为真
should <not> be equal:是否相等
should <not> start with:是否以某某开头
should <not> end with:是否以某某结束
should <not> match <regexp>:是否匹配正则表达式
get count :获取数量
get length:获取长度
get time:获取时间
length should be:长度是否等于
变量操作
set variable <if>:设置变量
set test variable:设置测试用例变量
set suite variable:设置测试套件变量
set global variable:设置全局变量
get variables :获取所有变量
get variable value:获取变量值
variable should <not> exist:变量是否存在
关键字操作
run keyword:运行关键字
run keywords:运行多个关键字
run keyword and return:运行关键字并返回结果
run keyword if test failed:测试用例失败后运行关键字
run keyword if:当条件满足时,运行关键字
run keyword unless:当条件不满足时,运行关键字
repeat keyword:重复运行某关键字
run keyword if all tests passed:所有测试用例通过后运行关键字
run keyword if any tests failed:任一测试用例失败后运行关键字
run keyword if timeout occurred:测试用例超时后运行关键字
流程控制
return from keyword:在程序中间进行返回,可提高效率
run keyword and return:实现闭包关键字处理,调用另一个关键字,然后把那个关键字的返回值作为当前关键字的返回值返回。
(2)collections库:集合操作,主要是list和dictionary的关键字
create list:创建列表
set list value:设置列表值
convert to list:把tuple或可遍历的列表对象转换成list
append to list:在list后面加新元素
insert into list:在list中间插入新元素
get from list:通过index获取元素
get index from list:获取元素在list的index
sort list:排序列表
reverse list:反转列表
remove from list:移除列表中指定位置的元素
remove value from list:从列表中移除指定的所有值
remove duplicates:从列表中移除重复项
(3)XML库
parse Xml:将一段文本信息处理成XML对象
get element <text>:获取XML的节点元素
add element:添加一个节点
clear element:清理掉所有的节点,保留了根节点<xml/>
set element tag:设置XML节点标签
set element text:设置XML节点文本
remove element attribute:移除XML节点属性
本文详细介绍了Robot Framework的自动化测试库,包括浏览器管理、cookie操作、数据库交互、接口自动化测试以及RF内置的关键字,如BrowserManagement、CookieKeywords、DatabaseLibrary、RequestsLibrary以及BuiltIn、Collections和XML库的相关功能,涵盖了自动化测试的多个方面。

934

被折叠的 条评论
为什么被折叠?



