Builtln库常用关键字

Converter类:类型转换

关键字解释
convert_to_integer
convert_to_binary
convert_to_octal将指定的内容转换为八进制形式
convert_to_hex将指定的内容转换为十六进制形式
convert_to_number将指定的内容转换为数字型
convert_to_string
convert_to_boolean
convert_to_bytes
create_list
create_dictionary

Verify类:断言类

关键字解释
fail表示测试用例执行失败,停止当前用例执行,下一个用例继续执行
fatal_error测试用例执行失败,停止当前及之后的所有测试用例的执行
should_not_be_true
should_be_true
should_be_equal
should_not_be_equal
should_not_be_equal_as_integers
should_be_equal_as_integers
should_not_be_equal_as_numbers
should_be_equal_as_numbers
should_not_be_equal_as_strings
should_be_equal_as_strings
should_not_start_with不应该以某个字符串为起始
should_start_with
should_not_end_with不应该以某个字符串为结束
should_end_with
should_not_contain不应该包含
should_contain
should_contain_any应该包含1、2、3、… 或 列表
should_not_contain_any
should_contain_x_times应该包含x次
get_count返回item2在item1中被找到的次数
should_not_match类似正则匹配
should_match
should_match_regexp正则匹配
should_not_match_regexp
get_length获取长度
length_should_be判定长度
should_be_empty
should_not_be_empty

Variables类:

关键字说明
get_variables获取一个包含当前作用域内的所有变量的字典
get_variable_value获取变量的值,若不存在,返回自定义值
variable_should_exist判断变量是否存在。若不存在,输出自定义msg
variable_should_not_exist判断变量是否存在。若存在,输出自定义msg
replace_variables替换变量值
set_variable设置变量值
set_test_variable设置测试用例变量
set_task_variable设置测试用例变量的别名,适合任务
set_suite_variable设置测试套件变量。对套件下所有用例生效
set_global_variable设置全局变量。对所有测试用例和套件生效

RunKeyword类

关键字说明示例
run_keyword运行关键字xx。返回运行结果
run_keywords运行多个关键字xx1、xx2run keyword xx1 and xx2
run_keyword_if当条件满足时运行关键字xx
run_keyword_unless当条件不满足时运行关键字 xx
run_keyword_and_ignore_error运行关键字并忽略错误
run_keyword_and_return_status获取关键字的返回值,主要是true or false
run_keyword_and_continue_on_failure失败后仍运行指定关键字
run_keyword_and_expect_error运行关键字并预期错误
repeat_keyword重复运行关键字
wait_until_keyword_succeeds等待关键字执行成功,可设置超时时间和重试间隔时间
set_variable_if在某种条件下,设置变量为xx1,否则为xx2
run_keyword_if_test_failed当用例失败时,运行关键字
run_keyword_if_test_passed当用例通过时,运行关键字
run_keyword_if_timeout_occurred当用例或关键字运行超时时,运行关键字
run_keyword_if_all_critical_tests_passed当关键用例通过时,运行关键字
run_keyword_if_any_critical_tests_failed
run_keyword_if_all_tests_passed当所有用例通过时,运行关键字
run_keyword_if_any_tests_failed

Control类

关键字说明
continue_for_loop跳出本层循环,执行下一层循环https://blog.csdn.net/weixin_30326745/article/details/97975588
continue_for_loop_if在某种条件下,跳出本层循环,执行下一层循环
exit_for_loop退出循环
exit_for_loop_if在某种条件下,退出循环
return_from_keyword类似python的return
return_from_keyword_if
run_keyword_and_return运行关键字并返回该关键字的结果
run_keyword_and_return_if当条件满足时,运行关键字并返回该关键字的结果
pass_execution标记测试用例执行成功
pass_execution_if当满足条件时标记测试用例执行成功

Misc类

关键字说明
sleep
catenate连接字符串
log
log_many
log_to_console
comment注释
set_log_level设置日志级别
reload_library重新检查指定库
import_library在test suite导入库
import_variables导入变量
import_resource导入资源
set_library_search_order判断关键字存在
get_time获取时间
evaluate计算python表达式并给出结果
call_method
regexp_escapepython中的re.escape()
set_test_message设置用例的message,在测试报告message列显示
set_test_documentation设置测试用例文档说明
set_suite_documentation设置测试套件 文档说明、
set_suite_metadata设置测试套件的原数据
set_tags设置tag
remove_tags去除tag
get_library_instance
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值