zoukankan      html  css  js  c++  java
  • RF

    官网网址:http://robotframework.org/robotframework/#standard-libraries

    https://blog.csdn.net/whackw/article/details/48804639

    编码问题:https://blog.csdn.net/m0_37615390/article/details/80798105

    https://blog.csdn.net/Allan_shore_ma/article/details/65441853?locationNum=8&fps=1

     https://blog.csdn.net/Allan_shore_ma/article/details/65441853?locationNum=10&fps=1

    selenium2library:https://www.cnblogs.com/hopchee/p/7922190.html

    # BuiltIn

    > 包含一些常用的关键字,能自动加载到内存。
    >
    > A. 各种数据类型,不同进制间的转换 ( Convert To Integer , Convert To Hex )
    > B. 各类验证 ( Should Be Equal )
    > c. 变量设置 ( Set Variable )
    > d. 关键字运行设置 ( Run Keyword If )
    > e. 流程控制类 ( exit for loop if )
    > f. 各类数据处理类 ( 日期处理,随机数,中文,正则表达式:evaluate )
    > g. 其他类 ( log sleep )

    ## Call Method

    > 参数:[ object | method_name | *args | **kwargs ]
    >
    > 使用参数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 | | |
    | Call Method | ${object} | kwargs | name=value | foo=bar |
    | Call Method | ${object} | positional | escaped=equals | |

    ## Catenate*

    >参数:[ *items ]
    >
    >连接给定参数,返回字符串。
    >
    >默认用空格连接参数项目,如果第一个参数为'SEPARATOR=<sep>',则使用”sep”来连接。

    | ${str1} = | Catenate | Hello | world | |
    | --------- | -------- | ------------- | ----- | ----- |
    | ${str2} = | Catenate | SEPARATOR=--- | Hello | world |

    ```
    ${str1} = 'Hello world'
    ${str2} = 'Hello---world'
    ```

    ## Comment***

    >参数:[ *messages ]
    >
    >注释,comment之后的同一行所有信息无效。

    ## Continue*

    ### Continue For Loop If

    >参数:[ condition ]
    >
    >如果条件生效,则跳过此轮循环。

    | :FOR | ${var} | IN | @{VALUES} | |
    | ---- | -------------------- | ---------------------- | --------- | ---- |
    | | Continue For Loop If | '${var}' == 'CONTINUE' | | |
    | | Do Something | ${var} | | |

    ```
    有列表@{VALUES},循环遍历,如果'${var}' != 'CONTINUE',则执行do something,然后继续遍历下一个元素。如果遍历到某个元素'${var}' == 'CONTINUE',则此轮循环结束,do something语句不执行,直接做下一轮循环。(FOR语句不结束)
    ```

    ### Continue For Loop

    >参数:[ ]
    >
    >强制性跳过此轮循环

    | :FOR | ${var} | IN | @{VALUES} | |
    | ---- | -------------- | ---------------------- | ----------------- | ---- |
    | | Run Keyword If | '${var}' == 'CONTINUE' | Continue For Loop | |
    | | Do Something | ${var} | | |

    ```
    跟Continue For Loop If起到的效果一样,两种不一样的写法,可以100%替代。只不过Continue For Loop If自带判断,Continue For Loop需要用run keyword if 去判断,根据判断结果运不运行。
    ```

    ## Convert To

    ### Convert To Binary

    >参数:[ item | base=None | prefix=None | length=None ]
    >
    >如果添加了base参数,则先内部使用[Convert To Integer](http://translate.googleusercontent.com/translate_c?hl=zh-CN&ie=UTF8&prev=_t&rurl=translate.google.com.hk&sl=en&tl=zh-CN&u=http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html%3Fr%3D2.6.3&usg=ALkJrhgMIkOCC2JIdCaKYdybQeMJs4RzxQ#Convert%20To%20Integer)转换为整数,然后再转换为二进制数字,以字符串的形式显示,比如”1011“。
    >
    >返回值可以包含可选的前缀(prefix)和最小长度(length不包含前缀和负号等)。如果返回值比要求的长度短,则使用0填充。

    | ${result1} = | Convert To Binary | 10 | | |
    | ------------ | ----------------- | ---- | -------- | --------- |
    | ${result2} = | Convert To Binary | F | base=16 | prefix=0b |
    | ${result3} = | Convert To Binary | -2 | prefix=B | length=4 |

    ```
    ${result1} = 1010
    ${result2} = 0b1111
    ${result3} = -B0010
    ```

    ### Convert To Boolean***

    >参数:[ item ]
    >
    >转换参数为布尔值true或false。
    >
    >如果参数是字符串'True'(不区分大小写)就返回真,为'False'就返回假;其他情况调用Python的'bool'的方法来判断。请参阅[http://docs.python.org/lib/truth.html](http://translate.googleusercontent.com/translate_c?hl=zh-CN&ie=UTF8&prev=_t&rurl=translate.google.com.hk&sl=en&tl=zh-CN&u=http://docs.python.org/lib/truth.html&usg=ALkJrhi7y1ZLKUXpm4Kv4rMpBmAD3CnfUA) 。
    >
    >

    ### Convert To Bytes

    >参数:[ input | input_type=text ]
    >
    >这个关键字跟python2的编码格式高度相关,很难使用到,如果真的要使用,具体看F5文档,很详细了。

    ### Convert To Hex

    >参数:[ item | base=None | prefix=None | length=None | lowercase=False ]
    >
    >转换参数为十六进制字符串。
    >
    >如果添加了base参数,则先内部使用[Convert To Integer](http://translate.googleusercontent.com/translate_c?hl=zh-CN&ie=UTF8&prev=_t&rurl=translate.google.com.hk&sl=en&tl=zh-CN&u=http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html%3Fr%3D2.6.3&usg=ALkJrhgMIkOCC2JIdCaKYdybQeMJs4RzxQ#Convert%20To%20Integer)转换为整数,然后再转换为十六进制数字,以字符串的形式显示,比如'FF0A'。
    >
    >返回值可以包含可选的前缀和最小长度(不包含前缀和负号等)。如果返回值比要求的长度短,则使用0填充。
    >
    >默认返回大写字符串,lowercase参数会转换值为小写(不包含前缀)。

    | ${result1} = | Convert To Hex | 255 | | |
    | ------------ | -------------- | ---- | --------- | ------------- |
    | ${result2} = | Convert To Hex | -10 | prefix=0x | length=2 |
    | ${result3} = | Convert To Hex | 255 | prefix=X | lowercase=yes |

    ```
    ${result1} = FF
    ${result2} = -0x0A
    ${result3} = Xff
    ```

    ### Convert To Integer

    >参数:[ item | base=None ]
    >
    >转换参数为整数。
    >
    >如果参数是字符串,则默认转为十进制整数。使用其他进制可以用base指定或者添加前缀,比如0b表示2进制,0o表示8进制,0x表示16进制。前缀只有当无base参数才可以添加,前缀的前面还可以添加加减等符号。
    >
    >语法不区分大小写并忽略空格

    | ${result} = | Convert To Interger | 100 | | # Result is 100 |
    | ----------- | ------------------- | ------ | ---- | ----------------- |
    | ${result} = | Convert To Interger | FF AA | 16 | # Result is 65450 |
    | ${result} = | Convert To Interger | 100 | 8 | # Result is 64 |
    | ${result} = | Convert To Interger | -100 | 2 | # Result is -4 |
    | ${result} = | Convert To Interger | 0b100 | | # Result is 4 |
    | ${result} = | Convert To Interger | -0x100 | | # Result is -256 |

    ### Convert To Number

    >参数:[ item | precision=None ]
    >
    >转换参数为浮点数。
    >
    >如果可选参数precision是正数或零,返回的四舍五入的值。负数则相当于修改-precision位数为0
    >
    >如果可选参数precision是负数,返回的四舍五入的值。

    | ${result} = | Convert To Number | 42.512 | | # Result is 42.512 |
    | ----------- | ----------------- | ------ | ---- | ------------------ |
    | ${result} = | Convert To Number | 42.512 | 1 | # Result is 42.5 |
    | ${result} = | Convert To Number | 42.512 | 0 | # Result is 43.0 |
    | ${result} = | Convert To Number | 42.512 | -1 | # Result is 40.0 |

    ### Convert To Octal

    >参数:[ item | base=None | prefix=None | length=None ]
    >
    >转换参数为八进制字符串。
    >
    >如果添加了base参数,则先内部使用[Convert To Integer](http://translate.googleusercontent.com/translate_c?hl=zh-CN&ie=UTF8&prev=_t&rurl=translate.google.com.hk&sl=en&tl=zh-CN&u=http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html%3Fr%3D2.6.3&usg=ALkJrhgMIkOCC2JIdCaKYdybQeMJs4RzxQ#Convert%20To%20Integer)转换为整数,然后再转换为八进制数字,以字符串的形式显示,比如'775''。
    >
    >返回值可以包含可选的前缀和最小长度(不包含前缀和负号等)。如果返回值比要求的长度短,则使用0填充。
    >
    >默认返回大写字符串,lowercase参数会转换值为小写(不包含前缀)。

    | ${result} = | Convert To Octal | 10 | | | # Result is 12 |
    | ----------- | ---------------- | ---- | ---------- | -------- | ------------------- |
    | ${result} = | Convert To Octal | -F | base=16 | prefix=0 | # Result is -017 |
    | ${result} = | Convert To Octal | 16 | prefix=oct | length=4 | # Result is oct0020 |

    ### Convert To String

    >参数:[ item ]
    >
    >转换参数为Unicode字符串。
    >
    >针对Python对象使用“__unicode__'或'__str__’方法。

    ## Create***

    ### Create Dictionary

    >参数:[ *items ]
    >
    >根据给定的 items 创建和返回字典。
    >
    >通常使用与变量表中创建的 &{dictionary} 变量相同的方式给出 键=值 语法。键和值都可以包含变量,键中可能的等号可以通过反斜杠(如escaped\=key=value)进行转义。也可以通过简单地使用类似 ${DICT} 来从现有字典中获取items。
    >
    >另外,可以指定项目,以便分别给出键和值。这个和 key=value 语法甚至可以组合,但是单独给定的 items 必须放在第一个。
    >
    >如果使用相同的密钥多次,则最后一个值优先。返回的字典是有序的,并且具有字符串作为键的值也可以使用方便的点访问语法(如${..key})来访问。

    | &{dict} = | Create Dictionary | key=value | foo=bar | | | # key=value syntax |
    | --------------- | ----------------------------------------------- | --------- | ------- | ------- | ---- | ------------------------ |
    | Should Be True | ${dict} == {'key': 'value', 'foo': 'bar'} | | | | | |
    | &{dict2} = | Create Dictionary | key | value | foo | bar | # separate key and value |
    | Should Be Equal | ${dict} | ${dict2} | | | | |
    | &{dict} = | Create Dictionary | ${1}=${2} | &{dict} | foo=new | | # using variables |
    | Should Be True | ${dict} == {1: 2, 'key': 'value', 'foo': 'new'} | | | | | |
    | Should Be Equal | ${dict.key} | value | | | | # dot-access |

    ### Create List

    >参数:[ *items ]
    >
    >根据指定参数创建列表。返回的列表都用来给 ${scalar} 和 @{list} 变量赋值。

    | @{list} = | Create List | a | b | c |
    | ----------- | ----------- | ---- | ---- | ---- |
    | ${scalar} = | Create List | a | b | c |
    | ${ints} = | Create List | ${1} | ${2} | ${3} |

    ## Evaluate***

    >参数:[ expression | modules=None | namespace=None ]
    >
    >用Python计算表达式并返回结果。
    >
    >modules参数可用于导入python模块,可用逗号分隔符分开多个模块。
    >
    >namespace参数可用于将自定义的评估命名空间作为字典传递。可能的模块被添加到这个命名空间中。这是RF框架2.8中的一个新特性。

    https://www.cnblogs.com/yrxns/p/6676582.html  时间模块

  • 相关阅读:
    Linux中./configure、make、make install详解
    VMware虚拟CentOS 6.5在NAT模式下配置静态IP地址及Xshell远程控制配置
    VMWare中Linux虚拟机设置静态IP上网的设置方法
    Linux下SSH远程连接断开后让程序继续运行解决办法
    弱网测试(一)
    算法的测试
    前端图片加载优化
    jpg/jpeg/png格式的区别与应用场景
    测试分类标准
    Mysql 日期与时间戳的相互转化
  • 原文地址:https://www.cnblogs.com/dongye95/p/9999628.html
Copyright © 2011-2022 走看看