String
Library version: | 3.0.4 |
---|---|
Library scope: | global |
Named arguments: | supported |
Introduction
A test library for string manipulation and verification.
String
is Robot Framework's standard library for manipulating strings (e.g. Replace String Using Regexp, Split To Lines) and verifying their contents (e.g. Should Be String).
Following keywords from BuiltIn
library can also be used with strings:
- Catenate
- Get Length
- Length Should Be
- Should (Not) Be Empty
- Should (Not) Be Equal (As Strings/Integers/Numbers)
- Should (Not) Match (Regexp)
- Should (Not) Contain
- Should (Not) Start With
- Should (Not) End With
- Convert To String
- Convert To Bytes
Shortcuts
Convert To Lowercase · Convert To Uppercase · Decode Bytes To String · Encode String To Bytes · Fetch From Left · Fetch From Right · Generate Random String · Get Line · Get Line Count · Get Lines Containing String ·Get Lines Matching Pattern · Get Lines Matching Regexp · Get Regexp Matches · Get Substring · Remove String · Remove String Using Regexp · Replace String · Replace String Using Regexp · Should Be Byte String ·Should Be Lowercase · Should Be String · Should Be Titlecase · Should Be Unicode String · Should Be Uppercase · Should Not Be String · Split String · Split String From Right · Split String To Characters · Split To Lines · Strip String
Keywords
Keyword | Arguments | Documentation | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Convert To Lowercase | string | Converts string to lowercase. Examples:
New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||
Convert To Uppercase | string | Converts string to uppercase. Examples:
New in Robot Framework 2.8.6. |
||||||||||||||||||||||||||||||
Decode Bytes To String | bytes, encoding,errors=strict | Decodes the given
Examples:
Use Encode String To Bytes if you need to convert Unicode strings to byte strings, and Convert To String in |
||||||||||||||||||||||||||||||
Encode String To Bytes | string, encoding,errors=strict | Encodes the given Unicode
Examples:
Use Convert To Bytes in |
||||||||||||||||||||||||||||||
Fetch From Left | string, marker | Returns contents of the If the See also Fetch From Right, Split String and Split String From Right. |
||||||||||||||||||||||||||||||
Fetch From Right | string, marker | Returns contents of the If the See also Fetch From Left, Split String and Split String From Right. |
||||||||||||||||||||||||||||||
Generate Random String | length=8, chars=[LETTERS][NUMBERS] | Generates a string with a desired The population sequence
Examples:
|
||||||||||||||||||||||||||||||
Get Line | string, line_number | Returns the specified line from the given Line numbering starts from 0 and it is possible to use negative indices to refer to lines from the end. The line is returned without the newline character. Examples:
Use Split To Lines if all lines are needed. |
||||||||||||||||||||||||||||||
Get Line Count | string | Returns and logs the number of lines in the given string. |
||||||||||||||||||||||||||||||
Get Lines Containing String | string, pattern,case_insensitive=False | Returns lines of the given The The match is case-sensitive by default, but giving Lines are returned as one string catenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Pattern and Get Lines Matching Regexp if you need more complex pattern matching. |
||||||||||||||||||||||||||||||
Get Lines Matching Pattern | string, pattern,case_insensitive=False | Returns lines of the given The
A line matches only if it matches the The match is case-sensitive by default, but giving Lines are returned as one string catenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Regexp if you need more complex patterns and Get Lines Containing String if searching literal strings is enough. |
||||||||||||||||||||||||||||||
Get Lines Matching Regexp | string, pattern,partial_match=False | Returns lines of the given See BuiltIn.Should Match Regexp for more information about Python regular expression syntax in general and how to use it in Robot Framework test data in particular. By default lines match only if they match the pattern fully, but partial matching can be enabled by giving the If the pattern is empty, it matches only empty lines by default. When partial matching is enabled, empty pattern matches all lines. Notice that to make the match case-insensitive, you need to prefix the pattern with case-insensitive flag Lines are returned as one string concatenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Pattern and Get Lines Containing String if you do not need full regular expression powers (and complexity).
|
||||||||||||||||||||||||||||||
Get Regexp Matches | string, pattern,*groups | Returns a list of all non-overlapping matches in the given string.
If no groups are used, the returned list contains full matches. If one group is used, the list contains only contents of that group. If multiple groups are used, the list contains tuples that contain individual group contents. All groups can be given as indexes (starting from 1) and named groups also as names. Examples:
=> ${no match} = [] ${matches} = ['the', 'tri'] ${one group} = ['he', 'ri'] ${named group} = ['he', 'ri'] ${two groups} = [('h', 'e'), ('r', 'i')] New in Robot Framework 2.9. |
||||||||||||||||||||||||||||||
Get Substring | string, start,end=None | Returns a substring from The Examples:
|
||||||||||||||||||||||||||||||
Remove String | string, *removables | Removes all
Use Remove String Using Regexp if more powerful pattern matching is needed. If only a certain number of matches should be removed, Replace String or Replace String Using Regexp can be used. A modified version of the string is returned and the original string is not altered. Examples:
New in Robot Framework 2.8.2. |
||||||||||||||||||||||||||||||
Remove String Using Regexp | string, *patterns | Removes This keyword is otherwise identical to Remove String, but the New in Robot Framework 2.8.2. |
||||||||||||||||||||||||||||||
Replace String | string, search_for,replace_with,count=-1 | Replaces
If the optional argument A modified version of the string is returned and the original string is not altered. Examples:
|
||||||||||||||||||||||||||||||
Replace String Using Regexp | string, pattern,replace_with,count=-1 | Replaces This keyword is otherwise identical to Replace String, but the If you need to just remove a string see Remove String Using Regexp. Examples:
|
||||||||||||||||||||||||||||||
Should Be Byte String | item, msg=None | Fails if the given Use Should Be Unicode String if you want to verify the The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Lowercase | string, msg=None | Fails if the given For example, The default error message can be overridden with the optional See also Should Be Uppercase and Should Be Titlecase. |
||||||||||||||||||||||||||||||
Should Be String | item, msg=None | Fails if the given With Python 2, except with IronPython, this keyword passes regardless is the With Python 3 and IronPython, this keyword passes if the string is a Unicode string but fails if it is bytes. Notice that with both Python 3 and IronPython, The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Titlecase | string, msg=None | Fails if given
For example, The default error message can be overridden with the optional See also Should Be Uppercase and Should Be Lowercase. |
||||||||||||||||||||||||||||||
Should Be Unicode String | item, msg=None | Fails if the given Use Should Be Byte String if you want to verify the The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Uppercase | string, msg=None | Fails if the given For example, The default error message can be overridden with the optional See also Should Be Titlecase and Should Be Lowercase. |
||||||||||||||||||||||||||||||
Should Not Be String | item, msg=None | Fails if the given See Should Be String for more details about Unicode strings and byte strings. The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Split String | string,separator=None,max_split=-1 | Splits the If a Split words are returned as a list. If the optional Examples:
See Split String From Right if you want to start splitting from right, and Fetch From Left and Fetch From Right if you only want to get first/last part of the string. |
||||||||||||||||||||||||||||||
Split String From Right | string,separator=None,max_split=-1 | Splits the Same as Split String, but splitting is started from right. This has an effect only when Examples:
|
||||||||||||||||||||||||||||||
Split String To Characters | string | Splits the given Example:
|
||||||||||||||||||||||||||||||
Split To Lines | string, start=0,end=None | Splits the given string to lines. It is possible to get only a selection of lines from Lines are returned without the newlines. The number of returned lines is automatically logged. Examples:
Use Get Line if you only need to get a single line. |
||||||||||||||||||||||||||||||
Strip String | string, mode=both,characters=None | Remove leading and/or trailing whitespaces from the given string.
If the optional Examples:
New in Robot Framework 3.0. |
Altogether 30 keywords.
Generated by Libdoc on 2018-04-25 23:41:29.
串
图书馆版本: | 3.0.4 |
---|---|
图书馆范围: | 全球 |
命名参数: | 支持的 |
介绍
用于字符串操作和验证的测试库。
String
是Robot Framework的标准库,用于操作字符串(例如,使用Regexp替换字符串,拆分为行)并验证其内容(例如,应该是字符串)。
来自BuiltIn
库的以下关键字也可以与字符串一起使用:
- 链状
- 得到长度
- 应该是长度
- 应该(不)是空的
- 应该(不)是平等的(如字符串/整数/数字)
- 应该(不)匹配(Regexp)
- 应该(不)包含
- 应该(不)开始
- 应该(不)结束
- 转换为字符串
- 转换为字节
快捷键
转换为小写 · 转换为大写 · 解码字节字符串 · 编码字符串的字节 · 取左起 · 取从右 · 生成随机字符串 · 找线 · 获取行计数 · 包含字符串获取行 · 获取线路匹配模式 · 得到正确的行匹配正则表达式 · 获取正则表达式匹配 · 获取子字符串 · 删除字符串 ·使用正则表达式删除字符串 · 替换字符串 · 使用正则表达式替换字符串 · 应该是字节字符串 · 应该是小写 · 应该是字符串 · 应该是标题 · 应该是Unicode字符串 · 应该全部是大写 · 不应该是字符串 · 分割字符串 · 分割字符串从右 · 分割字符串的字符 ·斯普利特行 · 地带字符串
关键词
关键词 | 参数 | 文档 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
转换为小写 | 串 | 将字符串转换为小写。 例子:
Robot Framework 2.8.6中的新功能。 |
||||||||||||||||||||||||||||||
转换为大写 | 串 | 将字符串转换为大写。 例子:
Robot Framework 2.8.6中的新功能。 |
||||||||||||||||||||||||||||||
将字节解码为字符串 | bytes, encoding,errors = strict | 使用给定的解码将给定
例子:
如果需要将Unicode字符串转换为字节字符串,请使用Encode String To Bytes;如果需要将任意对象转换为 Unicode字符串,请使用Convert To String in |
||||||||||||||||||||||||||||||
将字符串编码为字节 | 字符串, 编码, 错误=严格 |
例子:
Use Convert To Bytes in |
||||||||||||||||||||||||||||||
Fetch From Left | string, marker | Returns contents of the If the See also Fetch From Right, Split String and Split String From Right. |
||||||||||||||||||||||||||||||
Fetch From Right | string, marker | Returns contents of the If the See also Fetch From Left, Split String and Split String From Right. |
||||||||||||||||||||||||||||||
Generate Random String | length=8, chars=[LETTERS][NUMBERS] | Generates a string with a desired The population sequence
Examples:
|
||||||||||||||||||||||||||||||
Get Line | string, line_number | Returns the specified line from the given Line numbering starts from 0 and it is possible to use negative indices to refer to lines from the end. The line is returned without the newline character. Examples:
Use Split To Lines if all lines are needed. |
||||||||||||||||||||||||||||||
Get Line Count | string | Returns and logs the number of lines in the given string. |
||||||||||||||||||||||||||||||
Get Lines Containing String | string, pattern,case_insensitive=False | Returns lines of the given The The match is case-sensitive by default, but giving Lines are returned as one string catenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Pattern and Get Lines Matching Regexp if you need more complex pattern matching. |
||||||||||||||||||||||||||||||
Get Lines Matching Pattern | string, pattern,case_insensitive=False | Returns lines of the given The
A line matches only if it matches the The match is case-sensitive by default, but giving Lines are returned as one string catenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Regexp if you need more complex patterns and Get Lines Containing String if searching literal strings is enough. |
||||||||||||||||||||||||||||||
Get Lines Matching Regexp | string, pattern,partial_match=False | Returns lines of the given See BuiltIn.Should Match Regexp for more information about Python regular expression syntax in general and how to use it in Robot Framework test data in particular. By default lines match only if they match the pattern fully, but partial matching can be enabled by giving the If the pattern is empty, it matches only empty lines by default. When partial matching is enabled, empty pattern matches all lines. Notice that to make the match case-insensitive, you need to prefix the pattern with case-insensitive flag Lines are returned as one string concatenated back together with newlines. Possible trailing newline is never returned. The number of matching lines is automatically logged. Examples:
See Get Lines Matching Pattern and Get Lines Containing String if you do not need full regular expression powers (and complexity).
|
||||||||||||||||||||||||||||||
Get Regexp Matches | string, pattern,*groups | Returns a list of all non-overlapping matches in the given string.
If no groups are used, the returned list contains full matches. If one group is used, the list contains only contents of that group. If multiple groups are used, the list contains tuples that contain individual group contents. All groups can be given as indexes (starting from 1) and named groups also as names. Examples:
=> ${no match} = []
${matches} = ['the', 'tri']
${one group} = ['he', 'ri']
${named group} = ['he', 'ri']
${two groups} = [('h', 'e'), ('r', 'i')]
New in Robot Framework 2.9. |
||||||||||||||||||||||||||||||
Get Substring | string, start,end=None | Returns a substring from The Examples:
|
||||||||||||||||||||||||||||||
Remove String | string, *removables | Removes all
Use Remove String Using Regexp if more powerful pattern matching is needed. If only a certain number of matches should be removed, Replace String or Replace String Using Regexp can be used. A modified version of the string is returned and the original string is not altered. Examples:
New in Robot Framework 2.8.2. |
||||||||||||||||||||||||||||||
Remove String Using Regexp | string, *patterns | Removes This keyword is otherwise identical to Remove String, but the New in Robot Framework 2.8.2. |
||||||||||||||||||||||||||||||
Replace String | string, search_for,replace_with,count=-1 | Replaces
If the optional argument A modified version of the string is returned and the original string is not altered. Examples:
|
||||||||||||||||||||||||||||||
Replace String Using Regexp | string, pattern,replace_with,count=-1 | Replaces This keyword is otherwise identical to Replace String, but the If you need to just remove a string see Remove String Using Regexp. Examples:
|
||||||||||||||||||||||||||||||
Should Be Byte String | item, msg=None | Fails if the given Use Should Be Unicode String if you want to verify the The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Lowercase | string, msg=None | Fails if the given For example, The default error message can be overridden with the optional See also Should Be Uppercase and Should Be Titlecase. |
||||||||||||||||||||||||||||||
Should Be String | item, msg=None | Fails if the given With Python 2, except with IronPython, this keyword passes regardless is the With Python 3 and IronPython, this keyword passes if the string is a Unicode string but fails if it is bytes. Notice that with both Python 3 and IronPython, The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Titlecase | string, msg=None | Fails if given
For example, The default error message can be overridden with the optional See also Should Be Uppercase and Should Be Lowercase. |
||||||||||||||||||||||||||||||
Should Be Unicode String | item, msg=None | Fails if the given Use Should Be Byte String if you want to verify the The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Should Be Uppercase | string, msg=None | Fails if the given For example, The default error message can be overridden with the optional See also Should Be Titlecase and Should Be Lowercase. |
||||||||||||||||||||||||||||||
Should Not Be String | item, msg=None | Fails if the given See Should Be String for more details about Unicode strings and byte strings. The default error message can be overridden with the optional |
||||||||||||||||||||||||||||||
Split String | string,separator=None,max_split=-1 | Splits the If a Split words are returned as a list. If the optional Examples:
See Split String From Right if you want to start splitting from right, and Fetch From Left and Fetch From Right if you only want to get first/last part of the string. |
||||||||||||||||||||||||||||||
Split String From Right | string,separator=None,max_split=-1 | Splits the Same as Split String, but splitting is started from right. This has an effect only when Examples:
|
||||||||||||||||||||||||||||||
Split String To Characters | string | Splits the given Example:
|
||||||||||||||||||||||||||||||
Split To Lines | string, start=0,end=None | Splits the given string to lines. It is possible to get only a selection of lines from Lines are returned without the newlines. The number of returned lines is automatically logged. Examples:
如果您只需要获得一行,请使用获取行。 |
||||||||||||||||||||||||||||||
带状线 | string, mode = both, characters = None | 从给定字符串中删除前导和/或尾随空格。
如果 例子:
Robot Framework 3.0中的新功能。 |
共有30个关键字。
由Libdoc于2018-04-25 23:41:29 生成。
来源:oschina
链接:https://my.oschina.net/u/3447023/blog/1928043