RobotFramework_2. New projects, new use cases, use cases run and view the test report

RobotFramework use

Create a new project

Robotframework-ride Interface

Divided into four areas: the menu bar, toolbar, case and resource area, work area, as shown below:

Create a project

First, click File-New Project
pay attention to the type of switch Type: Directory Directory

Create a test suite

Right-click on the "test project" to select new Suite Options
Type: File Format: TXT

Create test cases

Right-click on the "test project" to select new Test Case

Import seleniumLibrary library

Web-based library of test cases need the support of selenium. Therefore, we in the process of using the library needs to be loaded SeleniumLibrary


Use SeleniumLibrary operate the web

RobotFramework viewing operation command help

In RobotFramework operation commands are referred to: a keyword
in Robotframework pressing the F5 , to open and to help the keyword search interface, as shown below:

And drivers ready browser

打开浏览器之前需要先准备相应浏览器的驱动程序driver
推荐使用chrome浏览器,对应驱动下载地址为:http://npm.taobao.org/mirrors/chromedriver/
注意每个版本的驱动程序只能驱动匹配的2-3个版本chrome浏览器,具体可以查看驱动版本目录下的notes.txt,比如:
----------ChromeDriver v2.46 (2019-02-01)----------
Supports Chrome v71-73
则表示2.46版本只能驱动chrome71-73版本
Firefox的驱动程序为GeckoDriver,IE的驱动程序为IEDriverServer
将相应的驱动程序下载之后解压为.exe文件,复制到一个加入了环境变量的路径下,比如:C:\Python27

打开浏览器Open Browser

作用:用指定的浏览器打开url网址
参数:url, browser=firefox, alias=None, remote_url=False, desired_capabilities=None, ff_profile_dir=None
url:打开的网址
browser:指定的浏览器,下表是seleniumLibrary支持的浏览器列表:

例如:

关闭浏览器Close BrowserClose All Browsers

Close Browser

关闭当前打开的浏览器窗口

Close All Browsers

关闭所有打开的浏览器并重置浏览器缓存
运行后,浏览器的数量下标将会被重置为1
这个关键字在测试用例或测试套件运行完毕前一定要被运行,确保所有的浏览器都被关闭

测试用例的运行

测试用例的运行有两种方式:
1. 通过edit->start按键,运行当前单个用例

  1. 通过菜单栏->运行按键,运行指定的用例

注意:如果一个用例也不勾选,点击运行按键,当前项目中所有测试套件中的所有测试用例将会依次执行

查看运行结果和测试报告

运行过后,可以通过控制台信息看到运行的结果(包括运行时间在内)

也可以通过点击Report点击查看详细测试报告

点击Log或在Report中点击log.html查看具体的步骤信息(当步骤Fail时,RFS会自动截图,贴在Log该步骤信息中)

 

 

 

 

Guess you like

Origin www.cnblogs.com/jeknight/p/11096956.html