当前位置:网站首页>RobotFramework入门(一)简要介绍及使用
RobotFramework入门(一)简要介绍及使用
2022-07-06 02:35:00 【Makasa】
前言
本章主要讲述Robotframework的简要介绍及使用
一、简要介绍
Robotframework:是一个基于Python语言开发的,可扩展的,是关键字驱动模式的自动化测试框架,Robotframework最新的版本是2019年7月份发布,7月份之前只支持python2.7,7月之后支持3.X的版本
首先简单说下【关键字驱动模式】和【数据驱动模式】的含义:
关键字驱动模式:就是将项目中的一些逻辑封装成关键字(一个函数名),然后我们可以调用不同的关键字组合实现不同的业务逻辑,从而驱动测试用例执行
例如:UI自动化中,我们每个用例步骤都可以写成一个方法,然后在robot中直接引用这个方法名即可另外数据驱动模式:就是实现参数化数据
例如:在API自动化中,比如框架用的pytest/unittest,我们一般都会实现参数化,将你的参数统一写在外部文件(excel、yaml、txt、csv…)中,然后通过读取外部文件进行参数化请求,这样的话之后我们只需要维护更改你的外部文件即可,常用的包:@ddt

Robotframework特点:
1)编辑用例简单,可以以robot,txt,tsv或者html的格式编写用例
2)自动生成html格式的测试报告和日志(HtmlTestRunner.py,allure)
3)不仅拥有自带的类库:
Buitini(测试库)
Collections(集合库)
Date Time(时间库)
ScreenShot(截屏库)
也很多其他实用的类扩展库:
SeleniumLibrary(web自动化测试)
RequestsLibrary(接口自动化测试)
AppiumLibrary(APP自动化测试)
4)可以根据项目的需要自定义一些关键字
5)可以使用GUI的方式运行,可以和SVN或者GIT及Jenkins持续集成
二、RobotFramework下载
#robotframework
pip install robotframework==3.1.2
#ride,可以进行GUI操作
pip install robotframework-ride==1.7.4.1
# 所有的扩展库下载后会统一放在python\Lib\site-packages文件夹下
# web自动化第三方库,进行UI自动化操作时下载,
pip install robotframework-selenium2library 3.0.0
pip install robotframework-seleniumlibrary 4.3.0
# 接口自动化测试库
pip install robotframework-requests
# appui自动化第三方库
pip install robotframework-appiumlibrary

三、Ride基本使用
1、创建ride桌面快捷方式
- 正常情况下安装robotframework-ride后会自动提示你创建桌面快捷入口,但偶尔也会创建失败,所以这里讲下ride快捷方式的创建

# 图标路径:你的python路径下\Lib..
D:\Mikasa_develop\Python36\Lib\site-packages\robotide\widgets\robot.ico

2、常用快捷键
# 1、查询关键字
F5
# 2、关键字自动补全
ctrl+shift+空格
四、简单robot用例实战

1、创建项目(New Project)
- File --> New Project,Type选择Directory,Format选择Robot

2、创建模块(New Directory)
- 鼠标右键点击项目 --> 选择New Directory

3、创建测试套件(New Suite)
- 鼠标右键点击模块 --> 选择New Suite

4、创建测试用例(New Test Case)
- 鼠标右键点击Suite --> 选择New Test Case

5、创建资源文件(New Resource)
- 资源文件是【自定义关键字】的载体
注意:只能在文件夹下面进行创建,并且是txt格式的

6、创建业务关键字(New User Keyword)
- 在资源文件下新建业务关键字

7、常用关键字用例编写
- 以下这些都是robot常用关键字,但其实我们自己的项目中进行UI/App自动化时,我们一般会使用自定义关键字


- 注意:关于编码的解决大家详细可以看下这篇文章,我就不做过多讲述了
http://t.zoukankan.com/panda-sweets-p-13730365.html

robot报告显示:

边栏推荐
- The third level of C language punch in
- Yyds dry inventory comparison of several database storage engines
- Shell脚本更新存储过程到数据库
- UE4 - how to make a simple TPS role (I) - create a basic role
- [Wu Enda machine learning] week5 programming assignment EX4 - neural network learning
- 模板_快速排序_双指针
- Global and Chinese markets of screw rotor pumps 2022-2028: Research Report on technology, participants, trends, market size and share
- Accident index statistics
- Global and Chinese markets of general purpose centrifuges 2022-2028: Research Report on technology, participants, trends, market size and share
- 有沒有sqlcdc監控多張錶 再關聯後 sink到另外一張錶的案例啊?全部在 mysql中操作
猜你喜欢

ReferenceError: primordials is not defined错误解决

好用的 JS 脚本

技术管理进阶——什么是管理者之体力、脑力、心力
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10](/img/89/1c2f98973b79e8d181c10d7796fbb5.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10

Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns

爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架

vs code保存时 出现两次格式化

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15](/img/72/0fe9cb032339d5f1ccf6f6c24edc57.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15

微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
随机推荐
球面透镜与柱面透镜
ftp上传文件时出现 550 Permission denied,不是用户权限问题
更换gcc版本后,编译出现make[1]: cc: Command not found
MySQL winter vacation self-study 2022 11 (9)
【MySQL 15】Could not increase number of max_open_files to more than 10000 (request: 65535)
Global and Chinese markets of nasal oxygen tubes 2022-2028: Research Report on technology, participants, trends, market size and share
Shell脚本更新存储过程到数据库
HDU_p1237_简单计算器_stack
High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
550 permission denied occurs when FTP uploads files, which is not a user permission problem
Reset nodejs of the system
怎么检查GBase 8c数据库中的锁信息?
Global and Chinese markets of screw rotor pumps 2022-2028: Research Report on technology, participants, trends, market size and share
2022 edition illustrated network pdf
Structural theme model (I) STM package workflow
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
Large scale DDoS attacks take Myanmar offline
I changed the driver to 5.1.35, but it is still the same error. I can succeed even now, but I will report this every time I do an SQL operation
【社区人物志】专访马龙伟:轮子不好用,那就自己造!
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9