*** Keywords ***
失败后继续运行
[Arguments] ${keyword} @{args}
Run Keyword And Continue On Failure ${keyword} @{args}
日志
[Arguments] @{msg}
log @{msg}
注释
comment
调用方法
[Arguments] ${object} ${method_name} @{args}
${res} Call Method ${object} ${method_name} @{args}
[Return] ${res}
连接
[Arguments] ${sep} @{args}
[Documentation] 可以使用 SEPARATOR= 指定连接字符,例如:
... 连接 SEPARATOR=*** \ \ aaa \ bbb \ ccc
... --------------------------------------------------
... 输出结果:aaa***bbb***ccc
${res} Catenate ${sep} @{args}
[Return] ${res}
继续for循环
Continue For Loop
条件成立继续for循环
[Arguments] ${arg}
Continue For Loop If ${arg}
转成二进制
[Arguments] ${item} ${base}= ${prefix}= ${length}=
${res} Convert To Binary ${item} ${base} ${prefix} ${length}
[Return] ${res}
转成bool
[Arguments] ${item}
${res} Convert To Boolean ${item}
[Return] ${res}
转成hex
[Arguments] ${item} ${base}= ${prefix}= ${length}= ${lowercase}=False
${res} Convert To Hex ${item} ${base} ${prefix} ${length} ${lowercase}
[Return] ${res}
转成int
[Arguments] ${item} ${base}=
${res} Convert To Integer ${item} ${base}
[Return] ${res}
转成Number
[Arguments] ${item} ${precision}=
[Documentation] precison 参数是保留位数,默认全部保存。
... Convert To Number 13.14 \ #结果:13.14
... Convert To Number 13.14 1 #结果:13.1
... Convert To Number 13.14 0 #结果:13.0
... Convert To Number 13.14 -1 #结果:10.0
${res} Convert To Number ${item} ${precision}
[Return] ${res}
转成Octal
[Arguments] ${item} ${base}= ${prefix}= ${length}=
${res} Convert To Octal ${item} ${base} ${prefix} ${length}
[Return] ${res}
转成String
[Arguments] ${item}
${res} Convert To String ${item}
[Return] ${res}
创建List
[Arguments] @{items}
@{list} Create List @{items}
[Return] @{list}
求值
[Arguments] ${expr} ${modules}=
[Documentation] ${status} = 求值 \ 0 < ${result} < 10
...
... ${down} = \ 求值 \ int(${result})
...
... ${up} = 求值 \ math.ceil(${result}) \ math
...
... ${random} = 求值 random.randint(0, sys.maxint) \ random,sys
${res} Evaluate ${expr} ${modules}
[Return] ${res}
退出For循环
Exit For Loop
条件成立退出For循环
[Arguments] ${arg}
Exit For Loop If ${arg}
失败
[Arguments] ${msg}= @{tag}
[Documentation] 使带有选择标签的测试失败,并给出失败信息,例如:
... 失败 "选择失败的case" "aaa" "bbb" "ccc"
... ------------------------------------
... 则带有 aaa bbb ccc 标签的测试案例都会失败,并附有 "选择失败的case" 信息
Fail ${msg} @{tag}
致命错误
[Arguments] ${msg}=
[Documentation] 停止所有测试案例执行
Fatal Error ${msg}
查找次数
[Arguments] ${item1} ${item2}
[Documentation] 从item1里面查找item2 出现的次数
${res} Get Count ${item1} ${item2}
[Return] ${res}
获取长度
[Arguments] ${item}
${res} Get Length ${item}
[Return] ${res}
获取Lib实例
[Arguments] ${name}
${res} Get Library Instance ${name}
[Return] ${res}
获取时间
[Arguments] ${format}=timestamp ${time_}=NOW
[Documentation] ${time}= 获取时间
...
... ${secs}= 获取时间 epoch
...
... ${year}= 获取时间 return year
...
... ${yyyy}= ${mm} ${dd} Get Time year,month,day
...
... @{time}= Get Time year month day hour min sec
...
... ${y} ${s}= Get Time seconds and year
... ---------------------------------------------------------------------
... ${time} = '2006-03-29 15:06:21'
...
... ${secs} = 1143637581
...
... ${year} = '2006'
...
... ${yyyy} = '2006', ${mm} = '03', ${dd} = '29'
...
... @{time} = ['2006', '03', '29', '15', '06', '21']
...
... ${y} = '2006'
...
... ${s} = '21'
${res} Get Time ${format} ${time_}
获取变量值
[Arguments] ${name} ${default}=
[Documentation] ${x}= 获取变量值 ${a} default
...
... ${y}= 获取变量值 ${a} ${b}
...
... ${z}= 获取变量值 ${z}
... -----------------------------------------------
... ${x} gets value of ${a} if ${a} exists and string "default" otherwise
...
... ${y} gets value of ${a} if ${a} exists and value of ${b} otherwise
...
... ${z} is set to Python `None` if it does not exist previously
${res} Get Variable Value ${name} ${default}
[Return] ${res}
获取变量
[Documentation] 返回当前测试案例范围内所有可用变量的字典
@{vars} Get Variables
[Return] @{vars}
导入库
[Arguments] ${name} @{args}
[Documentation] 导入给定名字的库和可选的操作参数:
...
... 当测试案例运行的时候,这个功能允许动态的导入Library.
...
... 导入库 MyLibrary
...
... 导入库 ${CURDIR}/../Library.py arg1 named=args
...
... 导入库 ${LIBRARIES}/Lib.java arg WITH NAME JavaLib
Import Library ${name} @{args}
导入资源
[Arguments] ${path}
[Documentation] 导入给出路径的资源文件:
...
... 导入资源 ${CURDIR}/resource.txt
...
... 导入资源 ${CURDIR}/../resources/resource.html
Import Resource ${path}
导入变量
[Arguments] ${path} @{args}
[Documentation] 导入给出路径的变量文件,并给出可选参数。
...
... 导入变量 ${CURDIR}/variables.py
...
... 导入变量 ${CURDIR}/../vars/env.py arg1 arg2
Import Variables ${path} @{args}
关键字应该存在
[Arguments] ${name} ${msg}=
[Documentation] 在当前运行测试案例范围内,关键字应该存在,否则测试失败。
Keyword Should Exist ${name} ${msg}
长度应该是
[Arguments] ${item} ${length} ${msg}=
Length Should Be ${item} ${length} ${msg}
多个日志
[Arguments] @{msg}
Log Many @{msg}
输出变量
[Arguments] ${lvl}=INFO
[Documentation] 输出当前所有范围内给定级别的日志
Log Variables ${lvl}
不操作
[Documentation] 什么都不做
No Operation
执行通过
[Arguments] ${msg} @{tags}
[Documentation] 需要参数: 信息,标签
...
... 作用:使带给定标签的测试案例通过,并添加描述信息。
Pass Execution ${msg} @{tags}
条件成立执行通过
[Arguments] ${condition} ${msg} @{tags}
[Documentation] 条件成立时,使带指定标签的案例测试通过,并给出信息。
Pass Execution If ${condition} ${msg} @{tags}
正则规避
[Arguments] @{patterns}
[Documentation] 这个功能可以使关键字在模式中正常匹配,而不会当做关键字去执行。
@{regx} Regexp Escape @{patterns}
[Return] @{regx}
删除标签
[Arguments] @{tags}
[Documentation] 例子:
... 删除标签 mytag something-* ?ython
Remove Tags @{tags}
重复关键字
[Arguments] ${times} ${name} @{args}
[Documentation] 指定关键字重复执行多少次:
...
... 重复关键字 5 Goto Previous Page
...
... 重复关键字 ${var} Some Keyword arg1 arg2
Repeat Keyword ${times} ${name} @{args}
替换变量
[Arguments] ${text}
Replace Variables ${text}
从关键字返回
[Arguments] @{return_values}
[Documentation] 从未关闭的关键字中返回值。
@{kwd} Return From Keyword @{return_values}
[Return] @{kwd}
Find Index
[Arguments] ${element} @{items}
${index} = Set Variable ${0}
: FOR ${item} IN @{items}
\ Return From Keyword If '${item}' == '${element}' ${index}
\ ${index} = Set Variable ${index + 1}
Return From Keyword ${-1} # Also [Return] would work here.
条件成立从关键字返回
[Arguments] ${condition} @{return_values}
@{val} Return From Keyword If ${condition} @{return_values}
[Return] @{val}
运行关键字
[Arguments] ${name} @{args}
[Documentation] 执行给定的关键和相关参数。
Run Keyword ${name} @{args}
运行关键字期望错误
[Arguments] ${expected_error} ${name} @{args}
Run Keyword And Expect Error ${expected_error} ${name} @{args}
运行关键字忽略错误
[Arguments] ${name} @{args}
Run Keyword And Ignore Error ${name} @{args}
运行关键字返回状态
[Arguments] ${name} @{args}
${stat} Run Keyword And Return Status ${name} @{args}
[Return] ${stat}
条件成立运行关键字
[Arguments] ${condition} ${kwd} @{args}
Run Keyword If ${condition} ${kwd} @{args}
所有最高级案例通过运行关键字
所有案例通过运行关键字
[Arguments] ${name} @{args}
Run Keyword If All Tests Passed ${name} @{args}
任意最高级案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Any Critical Tests Failed ${name} @{args}
任意案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Any Tests Failed ${name} @{args}
案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Test Failed ${name} @{args}
案例通过运行关键字
[Arguments] ${name} @{args}
Run Keyword If Test Passed ${name} @{args}
超时运行关键字
[Arguments] ${name} @{args}
Run Keyword If Timeout Occurred ${name} @{args}
条件失败运行关键字
[Arguments] ${condition} ${name} @{args}
Run Keyword Unless ${condition} ${name} @{args}
运行多个关键字
[Arguments] @{args}
[Documentation] 运行多个关键字 \ Initalize database \ \ \ | \ \ \ \ Start Server \ \ | \ \ \ Clear Logs \
Run Keywords @{args}
设置全局变量
[Arguments] ${var} ${val}
[Documentation] 设置全局变量 \ \ myvar \ \ \ value
Set Global Variable ${var} ${val}
设置库搜索命令
[Arguments] @{libs}
Set Library Search Order @{libs}
设置日志级别
[Arguments] ${lvl}
Set Log Level ${lvl}
设置测试套件文档
[Arguments] ${doc} ${append}=False ${top}=False
Set Suite Documentation ${doc} ${append} ${top}
设置测试套件标题
[Arguments] ${name} ${value} ${append}=False ${top}=False
Set Suite Metadata ${name} ${value} ${append} ${top}
设置测试套件变量
[Arguments] ${name} @{values}
Set Suite Variable ${name} @{values}
设置标签
[Arguments] @{tags}
Set Tags @{tags}
设置测试案例文档
[Arguments] ${doc} ${append}=False
Set Test Documentation ${doc} ${append}
设置测试案例信息
[Arguments] ${msg} ${append}=False
Set Test Message ${msg} ${append}
设置测试案例变量
[Arguments] ${name} @{values}
Set Test Variable ${name} @{values}
设置变量
[Arguments] ${values}
${var} Set Variable ${values}
[Return] ${var}
条件成立设置变量
[Arguments] ${condition} @{values}
${var} Set Variable IF ${condition} @{values}
[Return] ${var}
应该为空
[Arguments] ${item} ${msg}=
Should Be Empty ${item} ${msg}
应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Be Equal ${first} ${second} ${msg} ${values}
转成整数后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True ${base}=
[Documentation] 转成整型后应该相等 \ \ 42 \ ${42} \ 'Error message'
Should Be Equal As Integers ${first} ${second} ${msg} ${values} ${base}
转成数字之后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=Ture ${precision}=6
Should Be Equal As Numbers ${first} ${second} ${msg} ${values} ${precision}
转成字符串后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Be Equal As Strings ${first} ${second} ${msg} ${values}
应该为真
[Arguments] ${condition} ${msg}
Should Be True ${condition} ${msg}
应该包含
[Arguments] ${item1} ${item2} ${msg}= ${values}=True
Should Contain ${item1} ${item2} ${msg} ${values}
应该包含x次
[Arguments] ${item1} ${item2} ${count} ${msg}=
Should Contain X Times ${item1} ${item2} ${count} ${msg}
结尾应该是
[Arguments] ${str1} ${str2} ${msg}= ${values}=True
[Documentation] 如果str1不是以str2结尾,测试案例失败。
Should End With ${str1} ${str2} ${msg} ${values}
应该匹配
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Match ${string} ${pattern} ${msg} ${values}
应该匹配正则
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Match Regexp ${string} ${pattern} ${msg} ${values}
应该不为空
[Arguments] ${item} ${msg}=
Should Not Be Empty ${item} ${msg}
应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Not Be Equal ${first} ${second} ${msg} ${values}
转成整数后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True ${base}=
Should Not Be Equal As Integers ${first} ${second} ${msg} ${values}
转成数字后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=Ture ${precision}=6
Should Not Be Equal As Numbers ${first} ${second} ${msg} ${values}
转成字符串后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Not Be Equal As Strings ${first} ${second} ${msg} ${values}
应该为假
[Arguments] ${condition} ${msg}=
Should Not Be True ${condition} ${msg}
不应该包含
[Arguments] ${item1} ${item2} ${msg}= ${values}=True
Should Not Contain ${item1} ${item2} ${msg} ${values}
结尾应该不是
[Arguments] ${str1} ${str2} ${msg}= ${values}=True
Should Not End With ${str1} ${str2} ${msg} ${values}
不应该匹配
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Match ${string} ${pattern} ${msg} ${values}
不应该匹配正则
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Match Regexp ${string} ${pattern} ${msg} ${values}
开头不应该是
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Start With ${string} ${pattern} ${msg} ${values}
开头应该是
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Start With ${string} ${pattern} ${msg} ${values}
睡眠
[Arguments] ${time} ${reason}=
[Documentation] 睡眠 42
...
... 睡眠 1.5
...
... 睡眠 2 minutes 10 seconds
...
... 睡眠 10s \ 'Wait for a reply'
Sleep ${time} ${reason}
变量应该存在
[Arguments] ${name} ${msg}=
Variable Should Exist ${name} ${msg}
变量应该不存在
[Arguments] ${name} ${msg}=
Variable Should Not Exist ${name} ${msg}
等待关键字成功
[Arguments] ${timeout} ${retry_interval} ${name} @{args}
Wait Until Keyword Succeeds ${timeout} ${retry_interval} ${name} @{args}
失败后继续运行
[Arguments] ${keyword} @{args}
Run Keyword And Continue On Failure ${keyword} @{args}
日志
[Arguments] @{msg}
log @{msg}
注释
comment
调用方法
[Arguments] ${object} ${method_name} @{args}
${res} Call Method ${object} ${method_name} @{args}
[Return] ${res}
连接
[Arguments] ${sep} @{args}
[Documentation] 可以使用 SEPARATOR= 指定连接字符,例如:
... 连接 SEPARATOR=*** \ \ aaa \ bbb \ ccc
... --------------------------------------------------
... 输出结果:aaa***bbb***ccc
${res} Catenate ${sep} @{args}
[Return] ${res}
继续for循环
Continue For Loop
条件成立继续for循环
[Arguments] ${arg}
Continue For Loop If ${arg}
转成二进制
[Arguments] ${item} ${base}= ${prefix}= ${length}=
${res} Convert To Binary ${item} ${base} ${prefix} ${length}
[Return] ${res}
转成bool
[Arguments] ${item}
${res} Convert To Boolean ${item}
[Return] ${res}
转成hex
[Arguments] ${item} ${base}= ${prefix}= ${length}= ${lowercase}=False
${res} Convert To Hex ${item} ${base} ${prefix} ${length} ${lowercase}
[Return] ${res}
转成int
[Arguments] ${item} ${base}=
${res} Convert To Integer ${item} ${base}
[Return] ${res}
转成Number
[Arguments] ${item} ${precision}=
[Documentation] precison 参数是保留位数,默认全部保存。
... Convert To Number 13.14 \ #结果:13.14
... Convert To Number 13.14 1 #结果:13.1
... Convert To Number 13.14 0 #结果:13.0
... Convert To Number 13.14 -1 #结果:10.0
${res} Convert To Number ${item} ${precision}
[Return] ${res}
转成Octal
[Arguments] ${item} ${base}= ${prefix}= ${length}=
${res} Convert To Octal ${item} ${base} ${prefix} ${length}
[Return] ${res}
转成String
[Arguments] ${item}
${res} Convert To String ${item}
[Return] ${res}
创建List
[Arguments] @{items}
@{list} Create List @{items}
[Return] @{list}
求值
[Arguments] ${expr} ${modules}=
[Documentation] ${status} = 求值 \ 0 < ${result} < 10
...
... ${down} = \ 求值 \ int(${result})
...
... ${up} = 求值 \ math.ceil(${result}) \ math
...
... ${random} = 求值 random.randint(0, sys.maxint) \ random,sys
${res} Evaluate ${expr} ${modules}
[Return] ${res}
退出For循环
Exit For Loop
条件成立退出For循环
[Arguments] ${arg}
Exit For Loop If ${arg}
失败
[Arguments] ${msg}= @{tag}
[Documentation] 使带有选择标签的测试失败,并给出失败信息,例如:
... 失败 "选择失败的case" "aaa" "bbb" "ccc"
... ------------------------------------
... 则带有 aaa bbb ccc 标签的测试案例都会失败,并附有 "选择失败的case" 信息
Fail ${msg} @{tag}
致命错误
[Arguments] ${msg}=
[Documentation] 停止所有测试案例执行
Fatal Error ${msg}
查找次数
[Arguments] ${item1} ${item2}
[Documentation] 从item1里面查找item2 出现的次数
${res} Get Count ${item1} ${item2}
[Return] ${res}
获取长度
[Arguments] ${item}
${res} Get Length ${item}
[Return] ${res}
获取Lib实例
[Arguments] ${name}
${res} Get Library Instance ${name}
[Return] ${res}
获取时间
[Arguments] ${format}=timestamp ${time_}=NOW
[Documentation] ${time}= 获取时间
...
... ${secs}= 获取时间 epoch
...
... ${year}= 获取时间 return year
...
... ${yyyy}= ${mm} ${dd} Get Time year,month,day
...
... @{time}= Get Time year month day hour min sec
...
... ${y} ${s}= Get Time seconds and year
... ---------------------------------------------------------------------
... ${time} = '2006-03-29 15:06:21'
...
... ${secs} = 1143637581
...
... ${year} = '2006'
...
... ${yyyy} = '2006', ${mm} = '03', ${dd} = '29'
...
... @{time} = ['2006', '03', '29', '15', '06', '21']
...
... ${y} = '2006'
...
... ${s} = '21'
${res} Get Time ${format} ${time_}
获取变量值
[Arguments] ${name} ${default}=
[Documentation] ${x}= 获取变量值 ${a} default
...
... ${y}= 获取变量值 ${a} ${b}
...
... ${z}= 获取变量值 ${z}
... -----------------------------------------------
... ${x} gets value of ${a} if ${a} exists and string "default" otherwise
...
... ${y} gets value of ${a} if ${a} exists and value of ${b} otherwise
...
... ${z} is set to Python `None` if it does not exist previously
${res} Get Variable Value ${name} ${default}
[Return] ${res}
获取变量
[Documentation] 返回当前测试案例范围内所有可用变量的字典
@{vars} Get Variables
[Return] @{vars}
导入库
[Arguments] ${name} @{args}
[Documentation] 导入给定名字的库和可选的操作参数:
...
... 当测试案例运行的时候,这个功能允许动态的导入Library.
...
... 导入库 MyLibrary
...
... 导入库 ${CURDIR}/../Library.py arg1 named=args
...
... 导入库 ${LIBRARIES}/Lib.java arg WITH NAME JavaLib
Import Library ${name} @{args}
导入资源
[Arguments] ${path}
[Documentation] 导入给出路径的资源文件:
...
... 导入资源 ${CURDIR}/resource.txt
...
... 导入资源 ${CURDIR}/../resources/resource.html
Import Resource ${path}
导入变量
[Arguments] ${path} @{args}
[Documentation] 导入给出路径的变量文件,并给出可选参数。
...
... 导入变量 ${CURDIR}/variables.py
...
... 导入变量 ${CURDIR}/../vars/env.py arg1 arg2
Import Variables ${path} @{args}
关键字应该存在
[Arguments] ${name} ${msg}=
[Documentation] 在当前运行测试案例范围内,关键字应该存在,否则测试失败。
Keyword Should Exist ${name} ${msg}
长度应该是
[Arguments] ${item} ${length} ${msg}=
Length Should Be ${item} ${length} ${msg}
多个日志
[Arguments] @{msg}
Log Many @{msg}
输出变量
[Arguments] ${lvl}=INFO
[Documentation] 输出当前所有范围内给定级别的日志
Log Variables ${lvl}
不操作
[Documentation] 什么都不做
No Operation
执行通过
[Arguments] ${msg} @{tags}
[Documentation] 需要参数: 信息,标签
...
... 作用:使带给定标签的测试案例通过,并添加描述信息。
Pass Execution ${msg} @{tags}
条件成立执行通过
[Arguments] ${condition} ${msg} @{tags}
[Documentation] 条件成立时,使带指定标签的案例测试通过,并给出信息。
Pass Execution If ${condition} ${msg} @{tags}
正则规避
[Arguments] @{patterns}
[Documentation] 这个功能可以使关键字在模式中正常匹配,而不会当做关键字去执行。
@{regx} Regexp Escape @{patterns}
[Return] @{regx}
删除标签
[Arguments] @{tags}
[Documentation] 例子:
... 删除标签 mytag something-* ?ython
Remove Tags @{tags}
重复关键字
[Arguments] ${times} ${name} @{args}
[Documentation] 指定关键字重复执行多少次:
...
... 重复关键字 5 Goto Previous Page
...
... 重复关键字 ${var} Some Keyword arg1 arg2
Repeat Keyword ${times} ${name} @{args}
替换变量
[Arguments] ${text}
Replace Variables ${text}
从关键字返回
[Arguments] @{return_values}
[Documentation] 从未关闭的关键字中返回值。
@{kwd} Return From Keyword @{return_values}
[Return] @{kwd}
Find Index
[Arguments] ${element} @{items}
${index} = Set Variable ${0}
: FOR ${item} IN @{items}
\ Return From Keyword If '${item}' == '${element}' ${index}
\ ${index} = Set Variable ${index + 1}
Return From Keyword ${-1} # Also [Return] would work here.
条件成立从关键字返回
[Arguments] ${condition} @{return_values}
@{val} Return From Keyword If ${condition} @{return_values}
[Return] @{val}
运行关键字
[Arguments] ${name} @{args}
[Documentation] 执行给定的关键和相关参数。
Run Keyword ${name} @{args}
运行关键字期望错误
[Arguments] ${expected_error} ${name} @{args}
Run Keyword And Expect Error ${expected_error} ${name} @{args}
运行关键字忽略错误
[Arguments] ${name} @{args}
Run Keyword And Ignore Error ${name} @{args}
运行关键字返回状态
[Arguments] ${name} @{args}
${stat} Run Keyword And Return Status ${name} @{args}
[Return] ${stat}
条件成立运行关键字
[Arguments] ${condition} ${kwd} @{args}
Run Keyword If ${condition} ${kwd} @{args}
所有最高级案例通过运行关键字
所有案例通过运行关键字
[Arguments] ${name} @{args}
Run Keyword If All Tests Passed ${name} @{args}
任意最高级案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Any Critical Tests Failed ${name} @{args}
任意案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Any Tests Failed ${name} @{args}
案例失败运行关键字
[Arguments] ${name} @{args}
Run Keyword If Test Failed ${name} @{args}
案例通过运行关键字
[Arguments] ${name} @{args}
Run Keyword If Test Passed ${name} @{args}
超时运行关键字
[Arguments] ${name} @{args}
Run Keyword If Timeout Occurred ${name} @{args}
条件失败运行关键字
[Arguments] ${condition} ${name} @{args}
Run Keyword Unless ${condition} ${name} @{args}
运行多个关键字
[Arguments] @{args}
[Documentation] 运行多个关键字 \ Initalize database \ \ \ | \ \ \ \ Start Server \ \ | \ \ \ Clear Logs \
Run Keywords @{args}
设置全局变量
[Arguments] ${var} ${val}
[Documentation] 设置全局变量 \ \ myvar \ \ \ value
Set Global Variable ${var} ${val}
设置库搜索命令
[Arguments] @{libs}
Set Library Search Order @{libs}
设置日志级别
[Arguments] ${lvl}
Set Log Level ${lvl}
设置测试套件文档
[Arguments] ${doc} ${append}=False ${top}=False
Set Suite Documentation ${doc} ${append} ${top}
设置测试套件标题
[Arguments] ${name} ${value} ${append}=False ${top}=False
Set Suite Metadata ${name} ${value} ${append} ${top}
设置测试套件变量
[Arguments] ${name} @{values}
Set Suite Variable ${name} @{values}
设置标签
[Arguments] @{tags}
Set Tags @{tags}
设置测试案例文档
[Arguments] ${doc} ${append}=False
Set Test Documentation ${doc} ${append}
设置测试案例信息
[Arguments] ${msg} ${append}=False
Set Test Message ${msg} ${append}
设置测试案例变量
[Arguments] ${name} @{values}
Set Test Variable ${name} @{values}
设置变量
[Arguments] ${values}
${var} Set Variable ${values}
[Return] ${var}
条件成立设置变量
[Arguments] ${condition} @{values}
${var} Set Variable IF ${condition} @{values}
[Return] ${var}
应该为空
[Arguments] ${item} ${msg}=
Should Be Empty ${item} ${msg}
应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Be Equal ${first} ${second} ${msg} ${values}
转成整数后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True ${base}=
[Documentation] 转成整型后应该相等 \ \ 42 \ ${42} \ 'Error message'
Should Be Equal As Integers ${first} ${second} ${msg} ${values} ${base}
转成数字之后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=Ture ${precision}=6
Should Be Equal As Numbers ${first} ${second} ${msg} ${values} ${precision}
转成字符串后应该相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Be Equal As Strings ${first} ${second} ${msg} ${values}
应该为真
[Arguments] ${condition} ${msg}
Should Be True ${condition} ${msg}
应该包含
[Arguments] ${item1} ${item2} ${msg}= ${values}=True
Should Contain ${item1} ${item2} ${msg} ${values}
应该包含x次
[Arguments] ${item1} ${item2} ${count} ${msg}=
Should Contain X Times ${item1} ${item2} ${count} ${msg}
结尾应该是
[Arguments] ${str1} ${str2} ${msg}= ${values}=True
[Documentation] 如果str1不是以str2结尾,测试案例失败。
Should End With ${str1} ${str2} ${msg} ${values}
应该匹配
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Match ${string} ${pattern} ${msg} ${values}
应该匹配正则
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Match Regexp ${string} ${pattern} ${msg} ${values}
应该不为空
[Arguments] ${item} ${msg}=
Should Not Be Empty ${item} ${msg}
应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Not Be Equal ${first} ${second} ${msg} ${values}
转成整数后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True ${base}=
Should Not Be Equal As Integers ${first} ${second} ${msg} ${values}
转成数字后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=Ture ${precision}=6
Should Not Be Equal As Numbers ${first} ${second} ${msg} ${values}
转成字符串后应该不相等
[Arguments] ${first} ${second} ${msg}= ${values}=True
Should Not Be Equal As Strings ${first} ${second} ${msg} ${values}
应该为假
[Arguments] ${condition} ${msg}=
Should Not Be True ${condition} ${msg}
不应该包含
[Arguments] ${item1} ${item2} ${msg}= ${values}=True
Should Not Contain ${item1} ${item2} ${msg} ${values}
结尾应该不是
[Arguments] ${str1} ${str2} ${msg}= ${values}=True
Should Not End With ${str1} ${str2} ${msg} ${values}
不应该匹配
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Match ${string} ${pattern} ${msg} ${values}
不应该匹配正则
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Match Regexp ${string} ${pattern} ${msg} ${values}
开头不应该是
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Not Start With ${string} ${pattern} ${msg} ${values}
开头应该是
[Arguments] ${string} ${pattern} ${msg}= ${values}=True
Should Start With ${string} ${pattern} ${msg} ${values}
睡眠
[Arguments] ${time} ${reason}=
[Documentation] 睡眠 42
...
... 睡眠 1.5
...
... 睡眠 2 minutes 10 seconds
...
... 睡眠 10s \ 'Wait for a reply'
Sleep ${time} ${reason}
变量应该存在
[Arguments] ${name} ${msg}=
Variable Should Exist ${name} ${msg}
变量应该不存在
[Arguments] ${name} ${msg}=
Variable Should Not Exist ${name} ${msg}
等待关键字成功
[Arguments] ${timeout} ${retry_interval} ${name} @{args}
Wait Until Keyword Succeeds ${timeout} ${retry_interval} ${name} @{args}