本章主要介绍RF的循环,判断以及关键字Evaluate。
1. for循环
在RF中通过 :FOR 编写循环
:FOR ${i} in range 10 log ${i}
@{list} create list a b c :FOR ${i} IN @{list} \ Exit For Loop If '${i}'=='b' log ${i}
2. if判断
通过"run keyword if" 关键字可以编写if分支语句,还有很多其他的if判断,如Return From Keyword If等等
Run Keyword If ${i}>=90 log A ... ELSE IF ${i}>=80 log B ... ELSE IF ${i}>=60 log C ... ELSE log D
3. 强大的Evaluate
通过Evaluate可以使用 Python 语言中所提供的方法
${d} Evaluate random.randint(1,20) random
log ${d}
其中random是需要import的模块,random.randint(1,20)是调用random模块的方法和参数
${t} Evaluate time.localtime() time
log ${t}
这里就列举两个简单的例子,所有在python中能够运行的算式都可以使用Evaluate在RF中使用。
博客介绍了RF中的循环、判断及关键字Evaluate。在RF里,可用:FOR编写循环,通过“run keyword if”等关键字编写if分支语句。还能借助Evaluate使用Python语言提供的方法,如调用random模块,所有Python中能运行的算式都可在RF中用Evaluate实现。
517

被折叠的 条评论
为什么被折叠?



