Robot Framework学习(2):RIDE流程

Robot Framework学习(2):RIDE流程

1. 新建工程

Robot Framework学习(2):RIDE流程_第1张图片Robot Framework学习(2):RIDE流程_第2张图片

在Directory项目下可以创建测试套件

2. 创建测试套件 New Suite

Robot Framework学习(2):RIDE流程_第3张图片

Robot Framework学习(2):RIDE流程_第4张图片

在file测试套件下可以创建测试用例

3. 创建测试用例New Test Case

Robot Framework学习(2):RIDE流程_第5张图片

Robot Framework学习(2):RIDE流程_第6张图片

Robot Framework学习(2):RIDE流程_第7张图片

Aruguments: --loglevel error -d ./results    (设置日志等级和输出日志的路径)

Robot Framework学习(2):RIDE流程_第8张图片

Robot Framework学习(2):RIDE流程_第9张图片

Robot Framework学习(2):RIDE流程_第10张图片

 

robotframework有自己内建的库BuiltIn。关键字就是函数名或方法名

4. 导入第三方库(如果没有或错误,会报红),库文件路径:python安装目录/Lib\site-packages

Robot Framework学习(2):RIDE流程_第11张图片

F5可以查看

Robot Framework学习(2):RIDE流程_第12张图片

4.1 导入自定义库

将要导入的文件路径添加到【python安装目录/Lib\site-packages】下的.pth文件中,然后重启ride

5 用例编写和执行

最重要的就是如何编写用例了

以百度搜索为例

Robot Framework学习(2):RIDE流程_第13张图片

如果想改变输入框的输入词,则需要不停的复制case,为了减少冗余,可以做一个简单的分层,把搜索流程剥离成一个关键字,然后再不同的case中调用这个关键字,然后传递不同的参数,以进行不同数据在同一流程下测试。

5.1 创建User Keyword

选中case中所有的脚本,右键选择Extract Keyword

Robot Framework学习(2):RIDE流程_第14张图片

新建Resource(工程右键)

把Keyword移动到Resource下面

Robot Framework学习(2):RIDE流程_第15张图片Robot Framework学习(2):RIDE流程_第16张图片

 

 

Robot Framework学习(2):RIDE流程_第17张图片

在Resource下 新建登录Keyword

并定义两个变量和函数

Robot Framework学习(2):RIDE流程_第18张图片

新建case02调用

Robot Framework学习(2):RIDE流程_第19张图片

运行结果

Robot Framework学习(2):RIDE流程_第20张图片

Robot Framework学习(2):RIDE流程_第21张图片

 

设置标量

Robot Framework学习(2):RIDE流程_第22张图片Robot Framework学习(2):RIDE流程_第23张图片

在case中引用该标量

Robot Framework学习(2):RIDE流程_第24张图片

运行Start结果:

Robot Framework学习(2):RIDE流程_第25张图片

浏览器打开

Robot Framework学习(2):RIDE流程_第26张图片

 

 

你可能感兴趣的:(自动化测试,robotframework)