Robot Framework 是一个基于Python的通用自动化测试框架,采用关键字驱动测试(Keyword-Driven Testing)方法。
官网: https://robotframework.org/
安装Robot Framework
pip install robotframework
# Web测试,还需要安装SeleniumLibrary
pip install robotframework-seleniumlibrary
# 同selenium一样,需要下载WebDriver
快速上手
创建一个简单的测试项目,包含一个基本的Web测试用例。
1.创建项目结构
robot_framework_example/
├── tests/
│ └── example_test.robot
├── resources/
│ └── keywords.robot
└── results/
2.编写测试用例
在tests/example_test.robot文件中,编写以下内容:
*** Settings ***
Library SeleniumLibrary
Resource ../resources/keywords.robot
*** Variables ***
${URL} https://www.baidu.com
*** Test Cases ***
Test Example Page Title
Open Browser ${URL} chrome
Verify Page Title
Close Browser
3.编写关键字
在resources/keywords.robot文件中,编写自定义关键字:
*** Keywords ***
Open Example Page
[Arguments] ${url}
Open Browser ${url} chrome
Maximize Browser Window
Verify Page Title
Title Should Be 百度一下,你就知道
4.运行测试
在项目根目录下,通过命令行运行测试:
robot -d results tests
这会在results文件夹中生成测试报告和日志。
5.结果分析
运行测试后,可以通过浏览器查看Robot Framework在results文件夹下生成的报告和日志。
标签:Title,Robot,results,Framework,robot,安装,Browser From: https://www.cnblogs.com/rustling/p/18315058