robotframework笔记(介绍+基础关键字)robot framework库
Builtin:提供了⼀组通常需要的通⽤关键字
String:⽣成、修改和验证字符串的库
Screenshot:提供关键字捕捉桌⾯截图
XML:⽣成、修改和验证xml⽂件的库
DateTime:⽇期和时间转换库
……
Web⾃动化测试: SeleniumLibrary, Selenium2Library, Selenium2Library for Java、watir-robot等。Windows GUI测试: AutoltLibrary。
移动测试: Android library、 iOS library、 AppiumLibrary等。
数据库测试: Database Library(Java)、Database Library(Python)、 MongoDB library等。
⽂件对⽐测试: Diff Library。
HTTP测试:Http library(livetest)、Http library(Requests)等
……
robot framework库与单元测试框架⽐较
相同点:
setUp/tearDown
提供测试套件(⽤于运⾏⼀组测试⽤例的集合)
测试运⾏
⽣成HTML测试结果(主流的单元测试框架有⽣成HTML的扩展)
不同点:
语法
robot framework⾃建语法, unittest使⽤ Python语法。
⽀持库
robot framework⽀持特定库, unittest⽀持 Python的任意库。
@ 脚本对⽐, robot framework
*** Settings***
Library Selenium2Library
*** Test Cases ***
testcase
open browser www.baidu chrome
input text id=kw robot framework
click button id=su
close browser
说明:testcase之后的四条语句⾏⾸有四个空格
@ 脚本对⽐, unittest
from selenium import webdriver
import unittest
class Mytest(unittest.Testcase):
def testcase(self):
dr= webdriver.Chrome()
dr.find_element_by_id("kw").send_keys("robot framework")
dr.find_element_by_id("su").click()
dr.close()
if __name__ == '__main__':
unittest.main()
说明:定义的对象继承⾃unittest.Testcase,测试⽤例要以test开头-> def testcase(self) robot framework准备
Python2.x/Python3.x/(对python2⽀持更好)report是什么意思
robot framework
wxPython2.8.12.1(win32) (可选)
robot framework-ride(可选,是官⽅标准编辑器)
robot framework安装
【环境】 Win10 + Python3.7(仅安装了这⼀个版本)
C:\Users>pip show robotframework
WARNING: Package(s) not found: robotframework
C:\Users>pip install robotframework
…(省略)…
C:\Users\Learnrf>pip show robotframework
Name: robotframework
Version: 3.1.2
Summary: Generic automation framework for acceptance testing and robotic process automation (RPA) Home-page:
Author: Pekka Klärck
Author-email: peke@eliga.fi
License: Apache License 2.0
Location: c:\users\learnrf\appdata\local\programs\python\python37\lib\site-packages
Requires:
Required-by:
C:\Users\Learnrf>
编辑⽂件bot,内容如下
***Settings***
***Test Cases***
testcase
log robot framwork
执⾏命令 pybot bot,提⽰“pybot 不是内部命令”
【解决】到路径Python\Python37\Scripts,编辑⽂件 pybot.bat内容如下
@Echo off
python -m robot.run %*
再次执⾏命令 pybot bot,结果如下
输出了三个⽂件,report.html长这样 —>
log.html长这样 —>
robot framework编辑器
1.尝试在python3环境下安装RIDE
Win10+Python3,使⽤pip安装log如下:
C:\rf>pip install robotframework-ride
Collecting robotframework-ride
Downloading /packages/36/d5/ece871dc64e4022c5f8c6772c333a7c686bccec45825c463c5542c2a5eac/robotframework-ride-1.7.4 |████████████████████████████████| 1.2MB 43kB/s
Collecting wxPython
Downloading /packages/8a/12/08d58ad0a782aa003f2f4c19c2d2d8a55bc0141f9b925ea2f066732a7319/wxPython-4.0.7.post2-cp37 |████████████████████████████████| 23.0MB 43kB/s
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnection Collecting PyPubSub
Downloading /packages/1a/41/a0aceb552d8ec63bb1e8223d130f9dd0f736470036d75d708183b104a2cb/Pypubsub-4.0.3-py3-none |████████████████████████████████| 61kB 46kB/s
Collecting Pygments
Downloading /packages/be/39/32da3184734730c0e4d3fa3b2b5872104668ad6dc1b5a73d8e477e5fe967/Pygments-2.5.2-py2.py3- |████████████████████████████████| 901kB 18kB/s
Collecting Pywin32
Downloading /packages/bb/23/00fe4fbf9963f3bcb34a443eba0d0283fc51e5887d4045552c87490394e4/pywin32-227-cp37-cp37m- |████████████████████████████████| 9.1MB 31kB/s
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after
connection broken by 'ReadTimeoutError("HTTPSConnection Collecting pillow
Downloading /packages/88/6b/66f502b5ea615f69433ae1e23ec786b2cdadbe41a5cfb1e1fabb4f9c6ce9/Pillow-7.0.0-cp37-cp37m-w |████████████████████████████████| 2.0MB 33kB/s
Collecting six
Downloading /packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-an Requirement already satisfied: numpy; python_version >= "3.0" in c:\users\lenovo\appdata\local\programs\python\python37\lib\site-packages (from wxPython->ro Installing collected packages: pillow, six, wxPython, PyPubSub, Pygments, Pywin32, robotframework-ride
Running setup.py install for robotframework-ride ... done
Successfully installed PyPubSub-4.0.3 Pygments-2.5.2 Pywin32-227 pillow-7.0.0 robotframework-ride-1.7.4.1 six-1.14.0 wxPython-4.0.7.post2
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\rf>
然后会提⽰是否创建桌⾯快捷⽅式,点击确认即可。LOGO长这样
(1)例如Notepad++
可以使⽤ git 命令Clone或者下载到本地,这⾥下载到本地。
然后按照按照 README.md 操作:
语⾔->⾃定义语⾔格式...->导⼊->选择l,提⽰导⼊成功。
然后在“语⾔”中就可以到
注意:该语法⾼亮只适合扩展名为“.robot”的⽂件
ROBOT FRAMEWORK基础关键字
* robot framework的基础关键字封装 Builtin库中,它⾥⾯包含了最基础的⼀些关键字。
例如:打印、定义变量、定义数组、时间、分⽀语句、循环语句、调⽤ Python模块等。
*其它基础库: Dialogs、Collections、Operating System、Remote、ScreenshotString、Telnet、XML、 Process、Date Time
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论