RobotFramework常用关键字(1).pdf
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
RobotFramework常⽤关键字 常⽤关键字 虽然通过RIDE提供"填表"⼀样的写测试⽤例的⽅式。但它却⽀持强⼤的关键字功能,以及可以开发关键字的扩展能⼒。 Comment 注释功能,也可以使⽤python中的"#" Comment 注释 注释 #注释 log 打印。类似于print log Hello World set variable 定义变量 ${a} set variable Hello World!!! log ${a} catenate 连接对象 ${a} catenate hello world log ${a} SEPARATOR 对多个连接进⾏分割(必须⼤写) ${a} catenate SEPARATOR=, hello world log ${a} create list 创建列表 ${a} create list a b c log ${a} 通过 通过@{}定义列表 定义列表 必须使⽤ log many 打印 @{a} create list a b c log many @{a} get time 获取当前时间 ${a} get time log ${a} sleep 设置休眠时间 ${a} get time sleep 5 ${a} get time ${a} get time run keyword if 通过该语句可以编写if分⽀语句 ${a} set variable 59 run keyword if ${a}>=90 log 优秀 ... ELSE IF a >= 60and{a}<90 log ⼀般 ... ELSE log 菜 :FOR 实现循环 :FOR ${i} IN RANGE 10 log ${i} 列表遍历 列表遍历 @{lista} create list a b c :FOR ${a} in @{lista} log ${a} Exit For Loop If 退出循环的判断语句 @{lista} create list a b c :FOR ${a} IN @{lista} exit for loop if '${a}'=='b' log ${a} Evaluate 执⾏python中的⽅法 ${a} Evaluate random.randint(1000,9999) random log ${a} Import Library 导⼊标准和第三⽅模块或框架。⽐如调⽤unittest单元测试框架 Import Library unittest 导⼊外部py⽂件 Import Library c:/test.py ${sum} add 3 4 log ${sum} Import Library c:/test.py ${a} Evaluate int(4) ${b} Evaluate int(5) ${sum} add ${a} ${b} log ${sum} Take Screenshot 截取当前屏幕,Screenshot库为robot framework的标准类库,需⼿动加载 字典 字典 Collections库:该库为Robot Framework标准类库,它提供的关键字主要⽤于列表、索引、字典的处理。需要⼿动加载。 Create Dictionary 创建字典 ${dict} Create Dictionary sname Luffy age 19 Get Dictionary Items 获取字典中的key和value " item"GetDictionaryItems"{dict} " " log " ${item} "" Get Dictionary Keys 获取字典中的key ${keys} Get Dictionary keys ${dict} log ${keys} Get Dictionary Values 获取字典中的value ${values} Get Dictionary Values ${dict} log ${values} Get From Dictionary 根据key获取对应的value ${a} Get From Dictionary ${dict} sname log ${a} Processing math: 100%
- 粉丝: 168
- 资源: 3万+
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助