之前对robotframework-ride了解的不多,后来知道了引入Selenium2Lirary库后可以做web UI自动化测试,但发现和python没啥关系,今天学习了封装系统关键字算是和python联系上了,跟封装包提供调用函数类似。
1.封装一个库并调试通过、放在C:\Python27\Lib\site-packages目录下
2.ride中导入Library
3.查看导入的库
4.测试库是否正常工作
 
1.创建一个目录HelloWorld(这是库的名字,自己随便定义)
2.在目录中创建两个文件__init__.py,和helloworld.py,把helloworld.py调通,保证能够运行无语法错误。
helloworld.py文件内容,复制代码要小心,并一定调试通过再往下走。
# -*- coding:utf-8 -*-
'''
created by captain9 2017-1-2
''' __version__ = '0.1' class Hello(object):
def hi(self,name):
u'''接收一个名字,并问候.例如
| hi | xiaoming |
'''
print 'Hello, ' + name + '!' def decode(self,name):
return customerstr.decode('utf-8') if __name__ == "__main__":
name = u'xiaodong'
run = Hello()
run.hi(name)

__init__.py文件内容

# -*- coding:utf-8 -*-
# Copyright (c) 2010 Franz Allan Valencia See
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. from helloworld import Hello __version__ = '0.1' class HelloWorld(Hello):
"""
这是一个HelloWorld库,输入名字,输出问候。 """
ROBOT_LIBRARY_SCOPE = 'GLOBAL'

2.把HelloWorld目录放到C:\Python27\Lib\site-packages目录下

2.ride中导入Library,注意大小写敏感,这里是文件夹的名称:
若为黑色则为导入成功,红色为失败,helloword.py文件能否正常运行。
3.查看导入的库 F5或者Tools-Search Keywords
4.测试库是否正常工作
虽然关键字大小写不敏感,但我认为还是按照大小写敏感来写比较规范。
测试结果
 
好了,以后可以开发更多有用的关键字了。
 
Robot Framework is a Python-based, extensible keyword-driven test automation framework for end-to-end acceptance testing and acceptance-test-driven development (ATDD). It can be used for testing distributed, heterogeneous applications, where verification requires touching several technologies and interfaces.
 
参考:
Robot Framework自动化测试(五)--- 开发系统关键字 - 虫师 - 博客园

Robot Framework自动化测试(三)--- 封装系统关键字的更多相关文章

  1. Robot Framework分层、开发系统关键字

            开发系统关键字:http://www.cnblogs.com/fnng/p/4261293.html http://www.cnblogs.com/fnng/p/3969978.htm ...

  2. Robot Framework自动化测试三(selenium API)

    Robot  Framework  Selenium  API 说明: 此文档只是将最常用的UI 操作列出.更多方法请查找selenium2Library 关键字库. 一.浏览器驱动 通过不同的浏览器 ...

  3. Robot Framework自动化测试(五)--- 开发系统关键字

    最近一直在用robot framework 做自动化测试项目,老实说对于习惯直接使用python的情况下,被框在这个工具里各种不爽,当然,使用工具的好处也很多,降低了使用成本与难度:当然,在享受工具带 ...

  4. Robot Framework自动化测试框架核心指南-如何做好自动化测试平台框架的设计

    自动化测试如果需要能高效快速的支撑软件项目的测试,项目的快速迭代以及上线,除了以上我们介绍的需要许多的Lib来支持以及需要高效的去编写自动化测试案例外,还需要一个好的自动化测试框架平台来支撑我们的自动 ...

  5. Robot Framework自动化测试框架核心指南-如何使用Java编写自定义的RobotFramework Lib

    如何使用Java编写自定义的RobotFramework Lib 本文包括2个章节 1. Robot Frdamwork中如何调用java Lib库 2.使用 java编写自定义的Lib 本文作者为: ...

  6. Robot Framework 教程 (3) - Resource及关键字 的使用

    From:http://www.cnblogs.com/buaawp/p/4754399.html Robot Framework 教程 (3) - Resource及关键字 的使用 在进行软件自动化 ...

  7. Robot Framework 自动化测试

    Robot Framework 自动化测试 RIDE 是 Robot Framework 测试数据的编辑器.它使测试用例的创建.运行.测试项目的组织可以在图形界面下完成. 通过 RIDE 去学习和使用 ...

  8. Robot Framework 自动化测试 Selenium2Library 库 用法

    Robot Framework自动化测试Selenium2Library库详细用法 一.浏览器驱动   通过不同的浏览器执行脚本.   Open Browser Htpp://www.xxx.com ...

  9. Robot Framework自动化测试的应用

    Robot Framework自动化测试的应用(一) 最近尝试用Robot Framework代替之前全部采用python实现测试case,开始对Robot Framework进行些了解学习. 1. ...

随机推荐

  1. 学习lamda表达式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.L ...

  2. java Scanner与BufferedReader读取键盘输入性能比较

    java  Scanner与BufferedReader读取键盘输入性能比较            1.Scanner和BufferedReader 性能比较 在java中常见的从键盘获取输入的方式有 ...

  3. HTML中的转义字符

    HTML常用符号: 显示一个空格    < 小于 < <> 大于 > >& &符号 & &" 双引号 " &qu ...

  4. Hadoop集群(第10期)_MySQL关系数据库

    1.MySQL安装 MySQL下载地址:http://www.mysql.com/downloads/ 1.1 Windows平台 1)准备软件 MySQL版本:mysql-5.5.21-win32. ...

  5. java连接数据库时出现如下错误:

    java.lang.ClassNotFoundException: com.mysql.jdbc.driver at org.apache.catalina.loader.WebappClassLoa ...

  6. [转载]MongoDB C# 驱动教程

    本教程基于C#驱动 v1.6.x . Api 文档见此处: http://api.mongodb.org/csharp/current/. 简介 本教程介绍由10gen支持的,用于MongoDB的C# ...

  7. Linux巡检

    # uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # hostn ...

  8. solr的原子更新/局部更新

    solr支持三种类型的原子更新: set - to set a field. add - to add to a multi-valued field. inc - to increment a fi ...

  9. 读写UTF-8、Unicode文件(加上了文件头,貌似挺好用)

    conf配置文件一些为UTF-8和Unicode格式,这样便可良好的支持多语言,从网上查阅资料后,将读写UTF-8.Unicode文件写了几个最精简的函数,更新后加了是否写文件头的功能,以适应更多需要 ...

  10. Android include的使用

    如果在程序中多次用到一部分相同的布局,可以先将这部分布局定义为一个单独的XML,然后在需要的地方通过<include>引入,如下: main.xml <?xml version=&q ...