robotframework的学习笔记(十五)----robotframework标准库Collections
Collections库是RobotFramework用来处理列表和字典的库,官方文档是这样介绍的:A test library providing keywords for handling lists and dictionaries.
官方文档:http://robotframework.org/robotframework/latest/libraries/Collections.html
Keywords
Keyword | Arguments | Documentation | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Append To List | list_, *values |
Adds Example: => INFO : ${list} = [u'a', u'b'] |
||||||||||||||||||||||||||||||||||||
Combine Lists | *lists |
Combines the given Example: => 20170718 17:14:49.280 : INFO : ${l1} = [u'a', u'b'] |
||||||||||||||||||||||||||||||||||||
Convert To Dictionary | item |
Converts the given Mainly useful for converting other mappings to dictionaries. Use Create Dictionary from the BuiltIn library for constructing new dictionaries.New in Robot Framework 2.9. 将给定项目转换为Python dict类型。主要用于将其他映射转换为字典。 使用BuiltIn库中的“创建字典”来构建新的字典。 |
||||||||||||||||||||||||||||||||||||
Convert To List | item |
Converts the given Mainly useful for converting tuples(元组) and other iterable to lists. Use Create List from the BuiltIn library for constructing new lists. |
||||||||||||||||||||||||||||||||||||
Copy Dictionary | dictionary |
Returns a copy of the given dictionary. The given dictionary is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Copy List | list_ |
Returns a copy of the given list. The given list is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Count Values In List | list_, value, start=0, end=None |
Returns the number of occurrences of the given The search can be narrowed to the selected sublist by the Example:
=> ${x} = 1 |
||||||||||||||||||||||||||||||||||||
Dictionaries Should Be Equal | dict1, dict2, msg=None,values=True |
Fails if the given dictionaries are not equal. First the equality of dictionaries' keys is checked and after that all the key value pairs. If there are differences between the values, those are listed in the error message. The types of the dictionaries do not need to be same. See Lists Should Be Equal for more information about configuring the error message with The given dictionaries are never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Dictionary Should Contain Item | dictionary, key, value, msg=None |
An item of Value is converted to unicode for comparison. See Lists Should Be Equal for an explanation of |
||||||||||||||||||||||||||||||||||||
Dictionary Should Contain Key | dictionary, key, msg=None |
Fails if See List Should Contain Value for an explanation of The given dictionary is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Dictionary Should Contain Sub Dictionary | dict1, dict2, msg=None,values=True |
Fails unless all items in See Lists Should Be Equal for more information about configuring the error message with The given dictionaries are never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Dictionary Should Contain Value | dictionary, value, msg=None |
Fails if See List Should Contain Value for an explanation of The given dictionary is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Dictionary Should Not Contain Key | dictionary, key, msg=None |
Fails if See List Should Contain Value for an explanation of The given dictionary is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Dictionary Should Not Contain Value | dictionary, value, msg=None |
Fails if See List Should Contain Value for an explanation of The given dictionary is never altered by this keyword. |
||||||||||||||||||||||||||||||||||||
Get Dictionary Items | dictionary |
Returns items of the given Items are returned sorted by keys. The given Example:
=> ${items} = ['a', 1, 'b', 2, 'c', 3] |
||||||||||||||||||||||||||||||||||||
Get Dictionary Keys | dictionary |
Returns keys of the given If keys are sortable, they are returned in sorted order. The given Example:
=> ${keys} = ['a', 'b', 'c'] |
||||||||||||||||||||||||||||||||||||
Get Dictionary Values | dictionary |
Returns values of the given dictionary. Values are returned sorted according to keys. The given dictionary is never altered by this keyword. Example:
=> ${values} = [1, 2, 3] |
||||||||||||||||||||||||||||||||||||
Get From Dictionary | dictionary, key |
Returns a value from the given If the given The given dictionary is never altered by this keyword. Example:
=> ${value} = 2 |
||||||||||||||||||||||||||||||||||||
Get From List | list_, index |
Returns the value specified with an The given list is never altered by this keyword. Index Examples (including Python equivalents in comments):
=> ${x} = 'a' |
||||||||||||||||||||||||||||||||||||
Get Index From List | list_, value, start=0, end=None |
Returns the index of the first occurrence of the The search can be narrowed to the selected sublist by the Example:
=> ${x} = 3 |
||||||||||||||||||||||||||||||||||||
Get Match Count | list, pattern,case_insensitive=False,whitespace_insensitive=False |
Returns the count of matches to For more information on Examples:
New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||||||||
Get Matches | list, pattern,case_insensitive=False,whitespace_insensitive=False |
Returns a list of matches to For more information on Examples:
New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||||||||
Get Slice From List | list_, start=0, end=None |
Returns a slice of the given list between The given list is never altered by this keyword. If both Using Examples (incl. Python equivalents in comments):
=> ${x} = ['c', 'd'] |
||||||||||||||||||||||||||||||||||||
Insert Into List | list_, index, value |
Inserts Index If the absolute value of the index is greater than the length of the list, the value is added at the end (positive index) or the beginning (negative index). An index can be given either as an integer or a string that can be converted to an integer. Example:
=> ${L1} = ['xxx', 'a'] |
||||||||||||||||||||||||||||||||||||
Keep In Dictionary | dictionary, *keys |
Keeps the given If the given Example:
=> ${D5} = {'b': 2, 'd': 4} |
||||||||||||||||||||||||||||||||||||
List Should Contain Sub List | list1, list2, msg=None,values=True |
Fails if not all of the elements in The order of values and the number of values are not taken into account. See Lists Should Be Equal for more information about configuring the error message with |
||||||||||||||||||||||||||||||||||||
List Should Contain Value | list_, value, msg=None |
Fails if the If the keyword fails, the default error messages is |
||||||||||||||||||||||||||||||||||||
List Should Not Contain Duplicates | list_, msg=None |
Fails if any element in the The default error message lists all the elements that were found from the This keyword works with all iterables that can be converted to a list. The original iterable is never altered. |
||||||||||||||||||||||||||||||||||||
List Should Not Contain Value | list_, value, msg=None |
Fails if the See List Should Contain Value for an explanation of |
||||||||||||||||||||||||||||||||||||
Lists Should Be Equal | list1, list2, msg=None,values=True, names=None |
Fails if given lists are unequal. The keyword first verifies that the lists have equal lengths, and then it checks are all their values equal. Possible differences between the values are listed in the default error message like The error message can be configured using
Optional Examples:
If the items in index 2 would differ in the above examples, the error message would contain a row like |
||||||||||||||||||||||||||||||||||||
Log Dictionary | dictionary, level=INFO |
Logs the size and contents of the Valid levels are TRACE, DEBUG, INFO (default), and WARN. If you only want to log the size, use keyword Get Length from the BuiltIn library. |
||||||||||||||||||||||||||||||||||||
Log List | list_, level=INFO |
Logs the length and contents of the Valid levels are TRACE, DEBUG, INFO (default), and WARN. If you only want to the length, use keyword Get Length from the BuiltIn library. |
||||||||||||||||||||||||||||||||||||
Pop From Dictionary | dictionary, key, default= |
Pops the given By default the keyword fails if the given Example:
=> ${val} = 2 New in Robot Framework 2.9.2. |
||||||||||||||||||||||||||||||||||||
Remove Duplicates | list_ |
Returns a list without duplicates based on the given Creates and returns a new list that contains all items in the given list so that one item can appear only once. Order of the items in the new list is the same as in the original except for missing duplicates. Number of the removed duplicates is logged. New in Robot Framework 2.7.5. |
||||||||||||||||||||||||||||||||||||
Remove From Dictionary | dictionary, *keys |
Removes the given If the given Example:
=> ${D3} = {'a': 1, 'c': 3} |
||||||||||||||||||||||||||||||||||||
Remove From List | list_, index |
Removes and returns the value specified with an Index Example:
=> ${x} = 'a' |
||||||||||||||||||||||||||||||||||||
Remove Values From List | list_, *values |
Removes all occurrences of given It is not an error if a value does not exist in the list at all. Example:
=> ${L4} = ['b', 'd'] |
||||||||||||||||||||||||||||||||||||
Reverse List | list_ |
Reverses the given list in place. Note that the given list is changed and nothing is returned. Use Copy List first, if you need to keep also the original order.
=> ${L3} = ['c', 'b', 'a'] |
||||||||||||||||||||||||||||||||||||
Set List Value | list_, index, value |
Sets the value of Index Example:
=> ${L3} = ['a', 'xxx', 'yyy'] |
||||||||||||||||||||||||||||||||||||
Set To Dictionary | dictionary, *key_value_pairs,**items |
Adds the given Giving items as
=> ${D1} = {'a': 1, 'key': 'value', 'second': 2} Starting from Robot Framework 2.8.1, items can also be given as kwargs using
The latter syntax is typically more convenient to use, but it has a limitation that keys must be strings. If given keys already exist in the dictionary, their values are updated. |
||||||||||||||||||||||||||||||||||||
Should Contain Match | list, pattern, msg=None,case_insensitive=False,whitespace_insensitive=False |
Fails if See List Should Contain Value for an explanation of By default, pattern matching is similar to matching files in a shell and is case-sensitive and whitespace-sensitive. In the pattern syntax, If you prepend If If Non-string values in lists are ignored when matching patterns. The given list is never altered by this keyword. See also Examples:
New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||||||||
Should Not Contain Match | list, pattern, msg=None,case_insensitive=False,whitespace_insensitive=False |
Fails if Exact opposite of Should Contain Match keyword. See that keyword for information about arguments and usage in general. New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||||||||
Sort List | list_ |
Sorts the given list in place. The strings are sorted alphabetically and the numbers numerically. Note that the given list is changed and nothing is returned. Use Copy List first, if you need to keep also the original order. ${L} = [2,1,'a','c','b']
=> ${L} = [1, 2, 'a', 'b', 'c'] |
robotframework的学习笔记(十五)----robotframework标准库Collections的更多相关文章
- python3.4学习笔记(十五) 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
python3.4学习笔记(十五) 字符串操作(string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分割等) python print 不换行(在后面加上,end=''),prin ...
- (转载)西门子PLC学习笔记十五-(数据块及数据访问方式)
一.数据块 数据块是在S7 CPU的存储器中定义的,用户可以定义多了数据块,但是CPU对数据块数量及数据总量是有限制的. 数据块与临时数据不同,当逻辑块执行结束或数据块关闭,数据块中的数据是会保留住的 ...
- (C/C++学习笔记) 十五. 构造数据类型
十五. 构造数据类型 ● 构造数据类型概念 Structured data types 构造数据类型 结构体(structure), 联合体/共用体 (union), 枚举类型(enumeration ...
- JavaScript权威设计--JavaScript脚本化文档Document与CSS(简要学习笔记十五)
1.Document与Element和TEXT是Node的子类. Document:树形的根部节点 Element:HTML元素的节点 TEXT:文本节点 >>HtmlElement与 ...
- python 学习笔记十五 web框架
python Web程序 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. Python的WEB框架分为两类: 自己写socket,自 ...
- Python学习笔记011_模块_标准库_第三方库的安装
容器 -> 数据的封装 函数 -> 语句的封装 类 -> 方法和属性的封装 模块 -> 模块就是程序 , 保存每个.py文件 # 创建了一个hello.py的文件,它的内容如下 ...
- MySQL学习笔记十五:优化(2)
一.数据库性能评测关键指标 1.IOPS:每秒处理的IO请求次数,这跟磁盘硬件相关,DBA不能左右,但推荐使用SSD. 2.QPS:每秒查询次数,可以使用show status或mysqladmin ...
- Java基础学习笔记十五 集合、迭代器、泛型
Collection 集合,集合是java中提供的一种容器,可以用来存储多个数据. 在前面的学习中,我们知道数据多了,可以使用数组存放或者使用ArrayList集合进行存放数据.那么,集合和数组既然都 ...
- angular学习笔记(十五)-module里的'服务'
本篇介绍angular中的模块:module 在笔记(二)http://www.cnblogs.com/liulangmao/p/3711047.html里已经讲到过模块,这篇主要讲模块的 '服务' ...
- Java学习笔记十五:Java中的成员变量和局部变量
Java中的成员变量和局部变量 一:成员变量: 成员变量在类中定义,用来描述对象将要有什么 成员变量可以被本类的方法使用,也可以被其他类的方法使用,成员变量的作用域在整个类内部都是可见的 二:局部变量 ...
随机推荐
- JSONPath使用
JSONPath是fastjson在1.2.0之后支持的.JSONPath是一个很强大的功能.关于JSONPath的介绍请查看官方文档 JSONPath. 官方文档上给出了详细的说明以及使用.但是官方 ...
- Nexys3学习手记1:写在前面的话
偶然的机会,结识了xilinx的几位大牛,便毫不客气的从他们的手中接过了基于Spartan-6的由Digilent公司研发的Nexys3开发板(如图1所看到的).记得非常久非常久曾经初识FPGA的时候 ...
- python glob fnmatch 用于文件查找操作
參考: http://python.jobbole.com/81552/:Python模块学习:glob文件路径查找 http://blog.csdn.net/suiyunonghen/article ...
- 不用分支语句实现1+2+。。。+n
要求: 不使用乘除法.for.while .if.else.switch.case.以及A?B:C三元表达式 求1+2+3+...+n 此题思路有多种,能够用多态.构造函数.递归.和模板元. 我在看到 ...
- Cocos2d-x 3.0正式版及android环境搭建
开发环境是:mac + xcode + eclipse ,在win以下的环境和这个都是一样的,唯一不一样的就是环境变量的配置. 以下主要介绍cocos2d-x环境的设置以及android的环境搭建 1 ...
- 通过Graph 浏览器体验Microsoft Graph
作者:陈希章 发表于 2017年3月18日 上一篇介绍了Microsoft Graph的基本概念,接下来我们快速体验一下Microsoft Graph到底能做什么? 为了帮助开发人员直观和快速体验Mi ...
- Mybatis中模糊查询的各种写法(转)
. sql中字符串拼接 SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%');或者 <if test ...
- ERR Unsupported CONFIG parameter: notify-keyspace-events; nested exception is redis.clients.jedis.exceptions.JedisDataException
异常信息 时间:2017-04-05 15:53:57,361 - 级别:[ WARN] - 消息: [other] The web application [ROOT] appears to hav ...
- 《程序设计语言——实践之路(英文第三版)》【PDF】下载
<程序设计语言--实践之路(英文第三版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382234 内容简介 <程序设计语 ...
- 《设计模式:可复用面向对象软件的基础》【PDF】下载
<设计模式:可复用面向对象软件的基础>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382288 内容介绍 <设计模式:可复 ...