Robot framework自动化框架内置库(BuildIn)关键字大全
上一篇 /
下一篇 2017-07-20 09:38:06
/ 个人分类:自动测试工具
BuiltIn
版本:2.6.3
范围:global
命名参数:支持
介绍
BuiltIn是Robot Framework标准库,提供了常用关键字。它自动导入,从而始终可用。提供的关键字有用于验证的(e.g.Should Be
Equal,Should
Contain),转换的(e.g.Convert To
Integer),其他(e.g.Log,Sleep,Run Keyword
If,Set Global
Variable)。
所有关键字如下:
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
关键字介绍关键字 | 参数 | 文档 |
Call Method | object, method_name, *args | 使用参数args调用对象object的方法method_name。 方法可能返回值可以赋值给一个变量。 当找不到方法或者方法产生异常时,Keyword会失败。 例子: Call Method | ${hashtable} | put | myname | myvalue | ${isempty} = | Call Method | ${hashtable} | isEmpty | | Should Not Be True | ${isempty} | | | | ${value} = | Call Method | ${hashtable} | get | myname | Should Be Equal | ${value} | myvalue | | |
|
Catenate | Catenate | 连接给定参数,返回字符串。 默认用空格连接参数项目,如果第一个参数为'SEPARATOR=<sep>',则使用”sep”来连接. 例子: ${str1} = | Catenate | Hello | world | | ${str2} = | Catenate | SEPARATOR=--- | Hello | world | ${str3} = | Catenate | SEPARATOR= | Hello | world |
实际结果: => - ${str1} = 'Hello world' - ${str2} = 'Hello---world' - ${str3} = 'Helloworld' |
Comment | *messages | 在日志文件中以关键字参数形式显示指定信息。 Comment对参数不进行任何处理,仅仅是显示在日志中,用于显示简单信息。 如果要显示变量值,可以使用Log或Log Many关键字。 |
ConvertTo Binary | item, base=None, prefix=None, length=None | 转换参数为二进制字符串。 如果添加了base参数,则先内部使用Convert
To Integer转换为整数,然后再转换为二进制数字,以字符串的形式显示,比如”1011“。 返回值可以包含可选的前缀和最小长度(不包含前缀和负号等)。如果返回值比要求的长度短,则使用0填充。 例子: ${result} = | Convert To Binary | 10 | | | # Result is 1010 | ${result} = | Convert To Binary | F | base=16 | prefix=0b | # Result is 0b1111 | ${result} = | Convert To Binary | -2 | prefix=B | length=4 | # Result is -B0010 |
|
Convert To Boolean | item | 转换参数为布尔值true或false。 如果参数是字符串'True'(不区分大小写)就返回真,为'False'就返回假;其他情况调用Python的'bool'的方法来判断。请参阅http://docs.python.org/lib/truth.html。 |
Convert To Hex | item, base=None, prefix=None, length=None, lowercase=False | 转换参数为十六进制字符串。 如果添加了base参数,则先内部使用Convert To
Integer转换为整数,然后再转换为十六进制数字,以字符串的形式显示,比如'FF0A'。 返回值可以包含可选的前缀和最小长度(不包含前缀和负号等)。如果返回值比要求的长度短,则使用0填充。 默认返回大写字符串,lowercase参数会转换值为小写(不包含前缀)。 例子: ${result} = | Convert To Hex | 255 | | | # Result is FF | ${result} = | Convert To Hex | -10 | prefix=0x | length=2 | # Result is -0x0A | ${result} = | Convert To Hex | 255 | prefix=X | lowercase=yes | # Result is Xff |
|
Convert To Integer | item, base=None | 转换参数为整数。 如果参数是字符串,则默认转为十进制整数。使用其他进制可以用base指定或者添加前缀,比如0b表示2进制,0o |
收藏
举报
TAG: