当前位置:网站首页>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报告显示:

边栏推荐
- 更改对象属性的方法
- 有没有sqlcdc监控多张表 再关联后 sink到另外一张表的案例啊?全部在 mysql中操作
- Keyword static
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
- Template_ Quick sort_ Double pointer
- Dachang image library
- Redis skip table
- ReferenceError: primordials is not defined错误解决
- [robot hand eye calibration] eye in hand
- UE4 - how to make a simple TPS role (I) - create a basic role
猜你喜欢

Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle

数据工程系列精讲(第四讲): Data-centric AI 之样本工程

Zero basic self-study STM32 wildfire review of GPIO use absolute address to operate GPIO

UE4 - how to make a simple TPS role (I) - create a basic role

力扣今日題-729. 我的日程安排錶 I

一位博士在华为的22年

Zero foundation self-study STM32 - Review 2 - encapsulating GPIO registers with structures

纯Qt版中国象棋:实现双人对战、人机对战及网络对战

Looking at the trend of sequence modeling of recommended systems in 2022 from the top paper
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8](/img/16/33f5623625ba817e6e022b5cb7ff5d.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
随机推荐
Structural theme model (I) STM package workflow
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
有没有sqlcdc监控多张表 再关联后 sink到另外一张表的案例啊?全部在 mysql中操作
Pat grade a 1033 to fill or not to fill
Advanced technology management - what is the physical, mental and mental strength of managers
怎么检查GBase 8c数据库中的锁信息?
Network Security Learning - Web vulnerabilities (Part 1)
Minecraft 1.16.5 生化8 模组 2.0版本 故事书+更多枪械
Lecture 4 of Data Engineering Series: sample engineering of data centric AI
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
Shell脚本更新存储过程到数据库
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
Accident index statistics
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
深度解析链动2+1模式,颠覆传统卖货思维?
Compact lidar global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
我把驱动换成了5.1.35,但是还是一样的错误,我现在是能连成功,但是我每做一次sql操作都会报这个
2020.02.11
inherited constructors
A doctor's 22 years in Huawei