robot framework基础关键字封装在Builtin库中
log关键字:打印内容
1、定义变量: 关键字是 set variable

变量a:,需要用 {} 花括号括起来表示变量 set variable:(设置变量,这是库的关键字,会成蓝色) hello world :是变量的值
log:打印 ${a}:打印变量
2、定义列表:关键字是 create list

执行结果:每个字符串前面加U,是为了统一编码问题,将字符串转为Unicode编码

3、连接字符串:关键字Catenate

执行结果:

4、时间关键字:获取时间关键字:get time 休眠关键字:sleep

解释:${t}:时间变量 t ,get time 获取当前时间的关键字,然后打印出当前的实时间
sleep:休眠关键字,休眠5秒中后用变量打印出休眠后的时间

5、分支语句:
if
${a} set variable 65
run keyword if ${a}>=90 log 优秀
... else if ${a}>=80 log 良好
... else if ${a}>=60 log 及格
... else log 不及格

在run keyword if 下面的是三个英文字符的三个点,一定要有的,格式就是这样
6、循环语句关键字:for

解释:画红色的圈圈(就是:for 下面的一格一定要空出来),格式要求。冒号是英文冒号
7、强大的 Evaluate
随机循环random.randint(1000,9999)范围内的数字

工具(F5)-search keyword可以查看库中的所有关键字
8、遍历列表

用create list 关键字来定义列表(a,b,c),用“@{}” 来存放列表
通过“for” 循环来遍历@{abc}列表中的字符
执行结果:

网友评论