robotframework笔记4
Access Denied
> python sut/login.py create fred P4ssw0rd
SUCCESS > python sut/login.py login fred P4ssw0rd
Logged In
> python sut/login.py create fred short
Creating user failed: Password must be 7-12 characters long > python sut/login.py create fred invalid
Creating user failed: Password must be a combination of lowercase and
uppercase letters and numbers
Changing password failed: Access Denied
> python sut/login.py change-password fred P4ssw0rd short
Changing password failed: Password must be 7-12 characters long > python sut/login.py change-password fred P4ssw0rd NewP4ss
SUCCESS
robot --log custom_log.html --name Custom_Name QuickStart.rst
*** Test Cases ***
User can create an account and log in
Create Valid User fred P4ssw0rd
Attempt to Login with Credentials fred P4ssw0rd
Status Should Be Logged In User cannot log in with bad password
Create Valid User betty P4ssw0rd
Attempt to Login with Credentials betty wrong
Status Should Be Access Denied
*** Test Cases ***
User can change password
Given a user has a valid account
When she changes her password
Then she can log in with the new password
And she cannot use the old password anymore
*** Test Cases ***Invalid password[Template] Creating user with invalid password should fail
abCD5 ${PWD INVALID LENGTH}
abCD567890123 ${PWD INVALID LENGTH}
123DEFG ${PWD INVALID CONTENT}
abcd56789 ${PWD INVALID CONTENT}
AbCdEfGh ${PWD INVALID CONTENT}
abCD56+ ${PWD INVALID CONTENT}
*** Settings ***
Library OperatingSystem
Library lib/LoginLibrary.py
*** Keywords ***
Clear login database
Remove file ${DATABASE FILE} Create valid user
[Arguments] ${username} ${password}
Create user ${username} ${password}
Status should be SUCCESS Creating user with invalid password should fail
[Arguments] ${password} ${error}
Create user example ${password}
Status should be Creating user failed: ${error} Login
[Arguments] ${username} ${password}
Attempt to login with credentials ${username} ${password}
Status should be Logged In # Keywords below used by higher level tests. Notice how given/when/then/and
# prefixes can be dropped. And this is a comment. A user has a valid account
Create valid user ${USERNAME} ${PASSWORD} She changes her password
Change password ${USERNAME} ${PASSWORD} ${NEW PASSWORD}
Status should be SUCCESS She can log in with the new password
Login ${USERNAME} ${NEW PASSWORD} She cannot use the old password anymore
Attempt to login with credentials ${USERNAME} ${PASSWORD}
Status should be Access Denied
*** Variables ***
${USERNAME} janedoe
${PASSWORD} J4n3D0e
${NEW PASSWORD} e0D3n4J
${DATABASE FILE} ${TEMPDIR}${/}robotframework-quickstart-db.txt
${PWD INVALID LENGTH} Password must be 7-12 characters long
${PWD INVALID CONTENT} Password must be a combination of lowercase and uppercase letters and numbers
*** Test Cases ***
User status is stored in database
[Tags] variables database
Create Valid User ${USERNAME} ${PASSWORD}
Database Should Contain ${USERNAME} ${PASSWORD} Inactive
Login ${USERNAME} ${PASSWORD}
Database Should Contain ${USERNAME} ${PASSWORD} Active *** Keywords ***
Database Should Contain
[Arguments] ${username} ${password} ${status}
${database} = Get File ${DATABASE FILE}
Should Contain ${database} ${username}\t${password}\t${status}\n
*** Settings ***
Suite Setup Clear Login Database
Test Teardown Clear Login Database
*** Settings ***
Force Tags quickstart
Default Tags example smoke
import os.path
import subprocess
import sys classLoginLibrary(object): def__init__(self):
self._sut_path = os.path.join(os.path.dirname(__file__),
'..', 'sut', 'login.py')
self._status =''defcreate_user(self, username, password):
self._run_command('create', username, password) defchange_password(self, username, old_pwd, new_pwd):
self._run_command('change-password', username, old_pwd, new_pwd) defattempt_to_login_with_credentials(self, username, password):
self._run_command('login', username, password) defstatus_should_be(self, expected_status):
if expected_status !=self._status:
raiseAssertionError(Expected status to be '%s' but was '%s'.% (expected_status, self._status)) def_run_command(self, command, *args):
command = [sys.executable, self._sut_path, command] +list(args)
process = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self._status = process.communicate()[0].strip()
robotframework笔记4的更多相关文章
- robotframework笔记2
法文件和目录 层次结构安排测试用例构建如下: 在创建测试用例 测试用例文件 . 自动创建一个测试用例文件 测试套件 包含 测试用例文件. 一个目录包含测试用例文件形成一个更高级别的测试 套件. 这样一 ...
- robotframework笔记25
library文档工具(Libdoc) Libdoc是机器人框架内置的工具生成的关键字的文档 测试库和资源文件的HTML和XML格式. 前 格式适用于人类,后者 骑 和其他 工具. Libdoc显示库 ...
- robotframework笔记26
测试数据文档工具(Testdoc) Testdoc是机器人框架内置的工具生成高水平 根据测试用例文档. 创建的文档是在HTML中 格式和它包括名称.文档和其他元数据 测试套件和测试用例,以及和他们的顶 ...
- robotframework笔记22
创建测试库 支持的编程语言 机器人框架本身是用写的 Python 和自然的测试 库扩展它可以使用相同的实现 语言. 运行时框架上 Jython ,图书馆也可以 实现使用 Java . 纯Python代 ...
- robotframework笔记20
配置执行 选择测试用例 机器人框架提供了几个选择的命令行选项 执行测试用例. 也工作在相同的选项 后处理输出与 Rebot . 通过测试套件和测试用例的名称 测试套件和测试用例可以选择通过他们的名字的 ...
- robotframework笔记19
后处理输出 使用时自动测试 在测试执行报告和日志生成,并使用它 分别允许创建自定义报告和日志以及结合 和合并的结果. 使用Rebot 简介 rebot [options] robot_outputs ...
- robotframework笔记17
执行测试用例 基本用法 机器人框架从命令行执行测试用例,和 最终的结果是,在默认情况下,一个 输出文件 以XML格式和一个HTML 报告 和 日志 . 执行后,可以组合和输出文件 否则 进行后期处理 ...
- robotframework笔记11
测试用例的语法 基本语法 测试用例构造测试用例表中可用 关键词. 关键字可以进口 测试库 或 资源 文件 或创建的 关键字表 的测试用例文件 本身. 测试用例表中第一列包含测试用例的名称. 一个 测试 ...
- robotframework笔记8
文件变量 包含变量类型 Python 的 '.py' 扩展文件只不过是变量文件. # -*- Coding: utf-8 -*- var01 = "Hello " var02 = ...
随机推荐
- centos6.6下编译安装mysql5.6之后启动失败:Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
今天在编译安装mysql5.6时候出现Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysq ...
- Monkey类、People类和主类 E。
package jicheng; public class Monkey { private String s; public String getS() { return s; } public v ...
- IP地址验证
/** * 验证IP地址 * * @param 待验证的字符串 * @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false ...
- .Net 使用文件上传控件FileUpload上传图片
例1: 来源:http://long546324.iteye.com/blog/349946 Default.aspx文档: <%@ Page Language="C#" A ...
- js 立即执行函数,() .则前面的function 是表达式,不能是函数申明
fnName(); function fnName(){ ... }//正常,因为‘提升’了函数声明,函数调用可在函数声明之前 fnName(); var fnName=function(){ ...
- 初识redis——mac下搭建redis环境
一.redis简介 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有 ...
- Mono for Android布局控件属性小结
1. layout_weight 用于给一个线性布局中的诸多视图的重要度赋值. 所有的视图都有一个layout_weight值,默认为零,意思是需要显示 多大的视图就占据多大的屏幕空 间.若赋一个高于 ...
- Git学习(1)Git 简介
Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件. Git ...
- JavaWeb学习总结(十五)--过滤器的应用
一.解决全站字符乱码(post和get中文编码问题) 乱码问题: 获取请求参数中的乱码问题: POST请求:request.setCharacterEncoding("utf-8" ...
- RedHat 7配置yum源
卸载自带的yum软件包 rpm -e yum-utils--.el7.noarch --nodeps rpm -e yum-rhn-plugin--.el7.noarch --nodeps rpm - ...