We will use demo project as an example, go though QuickStart repo.

Install:

First you should have python & pip installed on your machine, then install robot framework libaraies.

pip install robotframework
pip install robotframework-selenium2library

Clone the repo.

Run:

robot login_tests

login_tests is the folder contains all the test cases. After running the tests, it should all pass.

Keywords:

You are able to define keywords, you can think 'keywords' is something like composeable function. It combines multi functions together as a single function. In Robot framkwork, it combines multi test cases into one single suit.

For example:

*** Keywords ***
User "${username}" logs in with password "${password}"
Input username ${username}
Input password ${password}
Submit credentials

"User "${username}" logs in with password "${password}"" is a new "keyword" which can be use elsewhere:

*** Test Cases ***
Valid Login
Given browser is opened to login page
When user "demo" logs in with password "mode"
Then welcome page should be open

"Given", "When" && "Then" are built in keyword in Robot framework.

And the keyword itself also combines multi keywords:

Input Username
[Arguments] ${username}
Input Text username_field ${username} Input Password
[Arguments] ${password}
Input Text password_field ${password} Submit Credentials
Click Button login_button

"Argumenets" here you can think it is function params, so when user use "Input Username", should also give a param.

"Input Text" is a built in keywords,from seleium libaray,  "username_field" is a id selector:

<td><input id="username_field" size="30" type="text"></td>

Variables:

resource.robot:

*** Variables ***
${SERVER} localhost:
${BROWSER} Firefox
${DELAY}
${VALID USER} demo
${VALID PASSWORD} mode
${INVALID USER} invalid
${INVALID PWD} invalid
${LOGIN URL} http://${SERVER}/
${WELCOME URL} http://${SERVER}/welcome.html
${ERROR URL} http://${SERVER}/error.html

You can define variables, and you can use those inside other files, just need to import the file contains variables:

*** Settings ***
Documentation A test suite with a single Gherkin style test.
...
... This test is functionally identical to the example in
... valid_login.robot file.
Resource resource.robot

Then you can use those like:

Login Should Have Failed
Location Should Be ${ERROR URL}
Title Should Be Error Page

Different way to write tests:

*** Settings ***
Documentation A test suite containing tests related to invalid login.
...
... These tests are data-driven by their nature. They use a single
... keyword, specified with Test Template setting, that is called
... with different arguments to cover different scenarios.
...
... This suite also demonstrates using setups and teardowns in
... different levels.
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Go To Login Page
Test Template Login With Invalid Credentials Should Fail
Resource resource.robot *** Test Cases ***
Invalid Username invalid ${VALID PASSWORD}
Invalid Password ${VALID USER} invalid
Invalid Username And Password invalid whatever
Empty Username ${EMPTY} ${VALID PASSWORD}
Empty Password ${VALID USER} ${EMPTY}
Empty Username And Password ${EMPTY} ${EMPTY} *** Keywords ***
Login With Invalid Credentials Should Fail
[Arguments] ${username} ${password}
Input Username ${username}
Input Password ${password}
Submit Credentials
Login Should Have Failed

or

*** Settings ***
Documentation A test suite containing tests related to invalid login.
...
... These tests are data-driven by their nature. They use a single
... keyword, specified with Test Template setting, that is called
... with different arguments to cover different scenarios.
...
... This suite also demonstrates using setups and teardowns in
... different levels.
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Go To Login Page
Test Template Login With Invalid Credentials Should Fail
Resource resource.robot *** Test Cases *** USER NAME PASSWORD
Invalid Username invalid ${VALID PASSWORD}
Invalid Password ${VALID USER} invalid
Invalid Username And Password invalid whatever
Empty Username ${EMPTY} ${VALID PASSWORD}
Empty Password ${VALID USER} ${EMPTY}
Empty Username And Password ${EMPTY} ${EMPTY} *** Keywords ***
Login With Invalid Credentials Should Fail
[Arguments] ${username} ${password}
Input Username ${username}
Input Password ${password}
Submit Credentials
Login Should Have Failed

[E2E] Robot Framework introduction的更多相关文章

  1. Robot Framework安装配置 Linux

    Simple introduction Robot Framework is a generic test automation framework for acceptance testing an ...

  2. Robot Framework 快速入门_英文版

    Copyright © Nokia Siemens Networks 2008 Licensed under the Apache License, Version 2.0 Table of Cont ...

  3. Robot Framework(十八) 支持工具

    5支持工具 5.1库文档工具(libdoc) libdoc是一种用于为HTML和XML格式的测试库和资源文件生成关键字文档的工具.前一种格式适用于人类,后者适用于RIDE和其他工具.Libdoc也没有 ...

  4. Robot Framework用户手册 (版本:3.0)

    版权信息:诺基亚网络和解决中心 本翻译尊重原协议,仅用于个人学习使用 1.开始: 1.1 介绍: Robot Framework是一个基于Python的,为终端测试和验收驱动开发(ATDD)的可扩展的 ...

  5. RIDE -- Robot Framework setup

    RobotFramework 是一款基于python 的可以实现关键字驱动和数据驱动并能够生成比较漂亮的测试报告的一款测试框架 这里使用的环境是 python-2.7.10.amd64.msi RID ...

  6. Robot Framework自动化测试 ---视频与教程免费分享

    当我第一次使用Robot Framework时,我是拒绝的.我跟老大说,我拒绝其实对于习惯了代码的自由,所以讨厌这种“填表格”式的脚本.老大说,Robot Framework使用简单,类库丰富,还可以 ...

  7. Robot Framework 的安装和配置(转载)

    Robot Framework 的安装和配置 在使用 RF(Rebot framework)的时候需要 Python 或 Jython 环境,具体可根据自己的需求来确定.本文以在有 Python 的环 ...

  8. 解决从jenkins打开robot framework报告会提示‘Opening Robot Framework log failed ’的问题

    最新的jenkins打开jenkins robot framework报告会提示如下 Verify that you have JavaScript enabled in your browser.  ...

  9. 在centos7中安装Robot Framework

    安装前景介绍: 最初,我们是在Windows环境下搭建Robot Framework来对我们的服务进行接口测试的(想知道如何在Windows下安装Robot Framework,可以参考我同事的博客h ...

随机推荐

  1. http压测工具wrk

    安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持LuaJIT和OpenSSL,不过不用担心,大多数类Unix系统都支持.安装wrk非常简单,只要从github上下载wrk源 ...

  2. 一些常用JS函数和技巧总结

    1.JS原生函数parseInt(),返回字符串的第一个数字,默认是十进制. 2.!!data.success  //强制转换成布尔类型

  3. python一切皆对象的理解

    min_error=pls(x_train, x_test, y_train, y_test) #这里我之前写的是error,但是前面有一个定义的error函数.所以导致出现了警告. 可能是因为pyt ...

  4. 12、python单步调试工具pdb

    pdb 第4种方式是启动Python的调试器pdb,让程序以单步方式运行,可以随时查看运行状态.我们先准备好程序: # err.py s = '0' n = int(s) print(10 / n) ...

  5. Linux中top命令参数详解

    此文摘自(https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316399.html) 简介 top命令是Linux下常用的性能分析工具,能够实 ...

  6. mysql 语句优化心得

    排序导致性能较慢 优化策略:1.尽量不使用排序 2.只查有索引的结果然后 内连接查询 select  bizchance0_.*  from biz_chance bizchance0_, biz_b ...

  7. sql server备份与还原 sql语句

    USE master DECLARE tb CURSOR LOCAL FOR SELECT 'Kill '+ CAST(Spid AS VARCHAR) FROM master.dbo.sysproc ...

  8. j2ee,jsp,servlet文件下载server端

    1.getOutputStream() has already been called for this response 报错的原因: 使用tomcat容器调用response.getOutputS ...

  9. [Android 性能优化系列]内存之提升篇--应用应该怎样管理内存

    大家假设喜欢我的博客,请关注一下我的微博,请点击这里(http://weibo.com/kifile),谢谢 转载请标明出处(http://blog.csdn.net/kifile),再次感谢 原文地 ...

  10. 微服务实战(三):深入微服务架构的进程间通信 - DockOne.io

    原文:微服务实战(三):深入微服务架构的进程间通信 - DockOne.io [编者的话]这是采用微服务架构创建自己应用系列第三篇文章.第一篇介绍了微服务架构模式,和单体式模式进行了比较,并且讨论了使 ...