RF快速上手文档 (RF Quick start documentation)

  • 简介 Summary

    robotframework是一款开源自动化框架,由python语言实现,用例脚本使用简单明了的表格语言编写。
    Robotframework is an open source automation framework implemented in the Python language; test case scripts are written in a simple and straightforward language.

  • 未安装RF的环境

    1.安装python:推荐python2.7版本,python3以上版本无法安装用例编写可视化工具ride
    2.安装robotframework(建议用pip安装 sudo pip install robotframework)
    3.安装IDE(可选,建议在本机安装,方便用例编写和调试运行,但在不支持图形界面的系统中无法安装)
      3.1安装wxpython(python可视化工具底层库)(sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-il8n
      3.2安装ride(sudo pip install robotframework-ride)
    最近升级了ubuntu16之后发现RF-ride有些问题,比如安装ubuntu 16上找不到wxpython2.8的源,或者使用pip安装默认ride版本时候报错说找不到Pywin32。
    其中第一个问题就是添加wxpython2.8网上的可用repo再使用apt下载,参考ubuntu16.04怎样才能安装 wxpython 2.8.12.1_7huaping的专栏-CSDN博客
    第二个问题则可以指定较低版本的ride进行pip安装,比如sudo pip uninstall robotframework-ride==1.5.2.1 

    安装成功后,运行pybot  --version,若正常显示版本则robotframework安装成功,运行ride.py,若ride程序运行成功则ride安装成功(若报程序找不到错误则先配置环境变量)

    When RF environment is not installed

    Follow the installation steps in~ 16.04 RF 安装
     
  • 创建用例 Create test case

    1.运行ride.py打开IDE / Run ride.py to open the IDE


    2.File->New Project新建项目 / File->New Project to create a new project
     

  • 3.在项目下右键创建测试集New Suite / Right click on the project to create the test suite -> New Suite

    4.在测试集上右键创建用例New Test Case / Create a test case by right-clicking on the test suite -> New Test Case

    5.使用RF内置的Builtin库中的关键字编写用例 / Write test cases using keywords in the built-in library of RF

     

  • 运行用例 Run test case

    1.直接点击ride工具中Run Tests按钮 / Just click the Run Tests button in the ride tool.
  • 2.通过pybot命令运行用例 / Run the test case with the pybot command
    pybot --outputdir ./ suite.txt (运行suite测试集中所有用例并把运行结果输出到当前目录./  Run all the test cases in the test suite and output the results to the current directory)
     
  • 查看运行结果 View test run results

    1.点击ride工具中Report按钮查看用例运行结果,点击Log按钮查看用例运行日志 / Click the Report button in the ride tool to view the test case run results, click the Log button to view the test case run log.

    2.打开运行结果目录中的report和log文件 / Open the report and log files in the run results directory
    3.分析结果 / Analysis result

  • 用例架构 Test case architecture:


    1.从本质上说,工程和测试集在创建完成以后没有区别(无论以项目或测试集创建的目录或文件,对项目的功能和影响是相同,且不能区分创建的目录到底是工程还是测试集),按照实际用途,一般来说,工程创建为目录,测试集创建为文件或目录(最底层一定是文件)
    Essentially, there is no difference between a project and a test suite after it has been created (regardless of the catalog or file created by the project or test suite, the functionality and impact of the project are the same, and it is not possible to distinguish whether the created directory is a project or a test suite) According to the actual use, in general, the project is created as a directory, and the test suite is created as a file or directory (the bottom layer must be a file)
    2.用例只能在文件形式的测试集/工程上创建
    Test cases can only be created on test suites/projects in the form of files
    3.资源,库的导入以及变量的声明在目录上不能生效
    Resources, library import and declaration of variables cannot take effect on the directory
     
  • 组件 Components:

  • 1.project

    自动化项目,可以包含多个模块多个suite / Automated project, can contain multiple modules and multiple suites
     
  • 2.suite

  • 测试集,可以是目录或文件,但用例上一层的suite一定是文件 / The test suite can be a directory or a file, but the suite above the test case must be a file.
  • 3.testcase

    测试用例,编写自动化脚本 / Test cases, write automated scripts

 

 

  • 4.variable

    RF变量,主要有scalar(${variable}),list(@{variable}),dictionary(&{variable})三种类型。按照作用域区分,可以分为全局变量(影响所有suite,用例,可以通过内置关键字set global variable或者运行命令中-v参数进行声明),suite变量(影响当前suite下所有用例,可以通过内置关键字set suite variable或在suite文件中声明),用例变量(影响当前用例,在当前用例中声明,可以直接通过set test variable内置关键字声明或通过关键字获得返回值),局部变量(user keyword内部变量,仅仅作用于关键字内部)
    RF variables, three types: scalar (${variable}), list (@{variable}), dictionary (&{variable}). According to the scope, it can be divided into global variables (affecting all suites, test cases, can be declared by the built-in keyword set global variable or running command -v parameter), suite variables (influencing all use cases under the current suite, can be built-in key word suite variable or declared in the suite file), test case variable (affecting the current test case, declared in the current test case, can be directly declared through the suite test variable or by the keyword to get the return value), local variables (user keyword internal Variables, only inside the keyword)
     
  • 5.用户关键字(user keyword)

    为了将部分底层关键字组装成一个新关键字,用户可以在用例项目中新建user keyword,以类似用例的编写方法封装用户关键字提供给用例使用,这时用户关键字可以通过自定义标题显示得更加清晰易懂。
    创建方法:在测试集或Resource上右键点击New User Keyword

    In order to assemble some of the existing keywords into a new keyword, the user can create a new user keyword in the project test case, and encapsulate the user keyword for the similar test case. In this case, the user keyword can be displayed by the custom title. More clear and easy to understand.

    Create method: Right click on New User Keyword on the test suite or Resource


     



     
  • 关键字库  Keyword library

    1.用例脚本中使用的方法称为关键字,关键字来源分为四部分:内置库(RF自带,如Builtin,String),第三方扩展库(需要网上下载,如SSHLibray),自定义库(按照RF规范需要编写python方法,xxx.py),用户关键字(用户在用例项目中把底层关键字进行封装)。
    The method used in the use case script is called a keyword. The keyword source is divided into four parts: built-in library (RF comes with, such as Builtin, String), third-party extension library (requires online download, such as SSHLibray), custom library (according to The RF specification requires writing a python method, xxx.py), a user keyword (the user encapsulates the underlying keyword in the test case project).
    2.除RF内嵌的"Builtin"库以外,所有库的使用需要先import library,内嵌库和三方扩展库都通过库名进行导入,自定义库通过导入.py文件导入。在ride中导入成功后,库名显示黑色,红色则表示导入失败(可能原因是找不到库名,依赖包有问题等)
    In addition to the "Builtin" library embedded in the RF, all libraries need to be imported first. The embedded library and the third-party extension library are imported by the library name. The custom library is imported by importing the .py file. After the import is successful in the ride, the library name is displayed in black; the red color indicates that the import failed (probably because the library name could not be found, the dependent package has a problem, etc.)
    3.导入库后按F5或者在用例中关键字上方按ctrl,查看关键字功能描述和使用方法
    After importing the library, press F5 or press ctrl above the keyword in the test case to view the keyword description and usage.
    4.目前测试使用得较多的三方库:SSHLibray(用于登录服务器,在服务器上执行各种命令),robotframework-httplibrary(用于调用http接口)
    Currently using a lot of third-party libraries: SSHLibray (used to log in to the server, execute various commands on the server), robotframework-httplibrary (used to call http interface)

 

 

  • Resource介绍 Introduction

    RF中的资源可以将需要用到的变量,库,用户关键字进行资源整合,方便管理,同时也可以减少用例中对库,变量等依赖的重复导入
    The resources in the RF can integrate the variables, libraries, and user keywords needed for resource management, which is convenient for management. It can also reduce the repeated import of dependencies on libraries, variables, etc. in the test case.


  •  
  • 文档资料 Documentation

    1.官方网站 Official website:http://robotframework.orgRobot Framework documentation
    2.齐涛RF基础教程 Qi Tao RF Foundation Tutorial:kok官方体育app_kok官方体育app官网-主页
    3.RF用例编写标准 RF test case writing standard:2 RF Style Guide
    4.RF源代码 RF source code:https://github.com/robotframework/robotframework
     
  • 后续


    1.如何自定义关键字库
    2.RDB项目常用库及关键字介绍
    3.RF常用方法技巧
    4.RF优缺点探讨
    5.???

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值