[E2E] Robot Framework introduction
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的更多相关文章
- Robot Framework安装配置 Linux
Simple introduction Robot Framework is a generic test automation framework for acceptance testing an ...
- Robot Framework 快速入门_英文版
Copyright © Nokia Siemens Networks 2008 Licensed under the Apache License, Version 2.0 Table of Cont ...
- Robot Framework(十八) 支持工具
5支持工具 5.1库文档工具(libdoc) libdoc是一种用于为HTML和XML格式的测试库和资源文件生成关键字文档的工具.前一种格式适用于人类,后者适用于RIDE和其他工具.Libdoc也没有 ...
- Robot Framework用户手册 (版本:3.0)
版权信息:诺基亚网络和解决中心 本翻译尊重原协议,仅用于个人学习使用 1.开始: 1.1 介绍: Robot Framework是一个基于Python的,为终端测试和验收驱动开发(ATDD)的可扩展的 ...
- RIDE -- Robot Framework setup
RobotFramework 是一款基于python 的可以实现关键字驱动和数据驱动并能够生成比较漂亮的测试报告的一款测试框架 这里使用的环境是 python-2.7.10.amd64.msi RID ...
- Robot Framework自动化测试 ---视频与教程免费分享
当我第一次使用Robot Framework时,我是拒绝的.我跟老大说,我拒绝其实对于习惯了代码的自由,所以讨厌这种“填表格”式的脚本.老大说,Robot Framework使用简单,类库丰富,还可以 ...
- Robot Framework 的安装和配置(转载)
Robot Framework 的安装和配置 在使用 RF(Rebot framework)的时候需要 Python 或 Jython 环境,具体可根据自己的需求来确定.本文以在有 Python 的环 ...
- 解决从jenkins打开robot framework报告会提示‘Opening Robot Framework log failed ’的问题
最新的jenkins打开jenkins robot framework报告会提示如下 Verify that you have JavaScript enabled in your browser. ...
- 在centos7中安装Robot Framework
安装前景介绍: 最初,我们是在Windows环境下搭建Robot Framework来对我们的服务进行接口测试的(想知道如何在Windows下安装Robot Framework,可以参考我同事的博客h ...
随机推荐
- php数组时按值传递还是按地址传递
php数组时按值传递还是按地址传递 一.总结 1.数组都是按值:php普通变量和数组的赋值(=)是按值传递,对象的赋值(=)是按址传递 2.对象和按值和按址:对象的clone(用clone关键字)是按 ...
- Shiro学习总结(10)——Spring集成Shiro
1.引入Shiro的Maven依赖 [html] view plain copy <!-- Spring 整合Shiro需要的依赖 --> <dependency> <g ...
- Java Servlet学习笔记(四)Servlet客户端Http请求
Servlet 客户端 HTTP 请求 当浏览器请求网页时,它会向 Web 服务器发送特定信息,这些信息不能被直接读取,因为这些信息是作为 HTTP 请求的头的一部分进行传输的.您可以查看 HTTP ...
- [selenium]-处理滚动条
转载于:https://blog.csdn.net/lilongsy/article/details/76142497 1.先把driver 强制转换为js,如下 JavascriptExecutor ...
- 洛谷——P1548 棋盘问题
https://www.luogu.org/problem/show?pid=1548#sub 题目描述 设有一个N*M方格的棋盘(l<=N<=100,1<=M<=100)(3 ...
- Codeforces Beta Round #24 D. Broken robot (打表找规律)
题目链接: 点击我打开链接 题目大意: 给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标. 让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 ...
- springmvc hibernate整合
今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多 了,Spring-Security的就留在下一篇吧,这篇主 ...
- 仿oschina 主界面的实现(二) -------Toolbar + DrawerLayout
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...
- 动态规划 —— 求解通配符问题(wildcard)
he?p help, heap, √ hellp, × *p*(必须包含 p,左右随意) help, papa, √ hello × *bb*(必须包含连续的两个 bb,左右随意) babbc √ 1 ...
- bootstrap 时间控件带(时分秒)选择器(需要修改才能显示,请按照参数说明后面的步骤进行修改)
1.控件下载地址:http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm,参数设置说明也在这个链接下面: 2.具体参数说明(复制原链接) ...