介紹下Robotframework接口测试--常用的API,掌握其api就可以做更多的操作啦!
======================
一、标准库 BuiltIn
提供的关键字有用于验证的(e.g. Should Be Equal, Should Contain),转换的(e.g. Convert To Integer),其他(e.g. Log, Sleep, Run Keyword If, Set Global Variable)。
1.Name: Call Method
Arguments: [object | method_name | *args | **kwargs ]
Calls the named method of the given object with the provided arguments.
调用对象object的方法method_name
2.Name: Catenate
Arguments:[ *items ]
Catenates the given items together and returns the resulted string.
连接给定参数,返回字符串(默认用空格连接)
例子:
| ${str1} = | Catenate | Hello | world | |
| ${str2} = | Catenate | SEPARATOR=--- | Hello | world | 
| ${str3} = | Catenate | SEPARATOR= | Hello | world | 
实际结果:
=>
- ${str1} = ‘Hello world‘
- ${str2} = ‘Hello---world‘
- ${str3} = ‘Helloworld‘
3.Name: Comment
Arguments:[ *messages ]
Displays the given messages in the log file as keyword arguments.
在日志文件中以关键字参数形式显示指定信息。
Comment对参数不进行任何处理,仅仅是显示在日志中,用于显示简单信息。
如果要显示变量值,可以使用Log 或 Log Many关键字。
4.Name: Continue For Loop
Arguments:[ ]
Skips the current for loop iteration and continues from the next.
跳出当前迭代,继续下一个迭代
5.Name: Convert To Binary
Arguments:[ item | base=base | prefix=prefix | length=length ]
Converts the given item to a binary string.
转换参数为二进制字符串
Examples: 
${result} =Convert To Binary    10     # Result is 1010
6.Name: Convert To Boolean 转换参数为布尔值true或false。
7.Name: Convert To Bytes 根据输入类型将给定的输入转换为字节。
8.Name: Convert To Hex Convert To Hex 转换参数为十六进制字符串
${result} =Convert To Hex 255 # Result is FF
9.Name: Convert To Integer 转换参数为整数。

10.Name: Convert To Number
Arguments:[ item | precision=precision ]
Converts the given item to a floating point number.
转换参数为浮点数。

注意:precision=-1时的使用
11.Name: Convert To Octal 转换参数为八进制字符串
12.Name: Convert To string 转换参数为Unicode字符串
13.Name: Create Dictionary
Arguments:[ *items ]
Creates and returns a dictionary based on the given items.
根据给定参数创建字典
 这里不能换成${dict}哦
 这里不能换成${dict}哦
======================
先學習這些吧!熟悉掌握這些API,讓其做更多的事,還有常用API(二)會後繼更新~
无想法就无成就!
原文:https://www.cnblogs.com/ww-xiaowei/p/10330733.html