之前对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. android开发之---文字居中---android中去掉标题栏

    1. 让textView里面的内容水平居中 :    android:gravity="center_horizontal" 2. 让textView控件在它的父布局里水平居中   ...

  2. 肾果手机App Store切换区域(无需Visa或者万事达)

    8月份在肾果官网买了个touch6,有时候需要换区去墙外下载app,然而一个个国家都要输入Visa或者万事达卡...今天终于找到一个不用输入信用卡号的区域:Canada!!! 办法(适用于8.X,7. ...

  3. c++ 输入一行字符串

    ]; //cin>>str1; 方式1 不能统计(录入)空格后的字符 cin.); //方式2 能统计空格后输入的字符 按回车键输入结束 get()会将换行符保存在序列里 //gets(s ...

  4. SDUT 2622 最短路径(Dijkstra)

    点我看题目 题意 :中文不详述. 思路 :因为这个题加了一个要求就是路径数目得是x的倍数.所以在原来算法的一维dis数组增加到二维,用来存走的路径数%x.也可以用spfa做. #include < ...

  5. Spring3 +mybatis3 之 MapperScannerConfigurer

    之前一直使用"org.mybatis.spring.mapper.MapperFactoryBean"这个类在spring中配置mybatis的dao接口,后来发现如果dao太多话 ...

  6. easyui源码翻译1.32--Combo(自定义下拉框)

    前言 扩展自$.fn.validatebox.defaults.使用$.fn.combo.defaults重写默认值对象.下载该插件翻译源码 自定义下拉框显示一个可编辑的文本框和下拉面板在html页面 ...

  7. 【Linux安全】安全口令策略设置

    命令: vim /etc/login.defs 默认设置: # Password aging controls: # # PASS_MAX_DAYS Maximum number of days a ...

  8. javascript模板引擎Mustache

    Mustache(英文本意:触须,胡须)是基于JavaScript实现的模版引擎,类似于JQuery Template,但是这个模版更加的轻量级,语法更加的简单易用,很容易上手. 下载:https:/ ...

  9. 【HDOJ】1241 Oil Deposits

    经典的BFS. #include <stdio.h> #include <string.h> #define MAXNUM 105 #define MAXROW 105 #de ...

  10. Sum of Digits / Digital Root

    Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...