RF常用关键字

常用关键字:

should be true   python表达式

1 ${res}  set variable  he
2 should be true  '${res}' in 'hello'    # 不加‘’号,代表变量
3 # python表达式,空格不能多于2个,$res只能应用在表达式中
4 should be true  $res in 'hello'     # 直接引用字符串本身
5 should be equal  ${1*2} ${2} # {}内会根据python语法进行计算,这种会计算里面的值并转换为int

  

 1 定义变量
 2     ${var1}     set variable  word   #定义字面量
 3     ${var2}     convert to integer  2  # 定义整型
 4     ${var3}     convert to number  4.4  # 定义数字,可以是浮点数
 5     log to console  ${var1}
 6     log to console  ${var2}
 7     log to console  ${var3}
 8     log to console  ${4+3}  # 7  数字变量
 9 常用关键字
10 # should be true  注意点:数为python表达式,布尔类型,空格不能多于2个,变量前面加一个$
11 # should be true 它的参数本身是python 表达式语句,RF会直接用python解释器 的eval函数,来解释这个参数表达式。
12     ${var1}     set variable  word
13     ${var2}     convert to integer  2  # 定义整型
14     ${var3}     convert to integer  3  # 定义整型
15     ${var4}     create list             #定义空列表
16     should be true  3==2   # 参数为python表达式,布尔类型,空格不能多于2个,变量前面加一个$
17     should be true  []    # 空列表为False
18     should contain  hello     he   #第一个参数包含第二个参数
19     should start with  hello    h  # 第一个参数以h开头
20     should end with  hello  o   # 第一个参数以o结尾
21     should be empty  ${var4}    # 判断是否为空
22 
23 判断两个对象是否相等
24 #    should be equal  ${var2}    ${var3}
25     should be equal  a  a
26     should be equal as integers  10     010   #转换成数字对象比较,结果是true
27     should be equal  10     010     #字符串对象比较,结果是False
28     should be equal as numbers  1.2     1.2
29 字符串比较
30 # $符号加变量,直接引用变量本身
31     ${var}  set variable  word
32 #   报错Evaluating expression 'word == 'word'' failed: NameError: name 'word' is not defined
33 #    should be true  ${var} == 'word'
34     should be true  '${var}' == 'word'  #True
35     should be true  $var == 'word'  #True
36 整数比较
37     ${var}  convert to integer  2
38     log to console  ${2}   # 2
39     should be true  ${var} == ${2}
40     should be true  $var == ${2}
41     should be true  $var == 2
原文地址:https://www.cnblogs.com/aiyumo/p/12390810.html