之前对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. char型字符串(数组)与string型字符串 指针与引用

    一.常指针: int *const p;    //指针不可改变,但是指针指向的数据可以改变. 指向常量的指针: const int *p;    //指针可以改变,但是指针指向的数据不可以改变. 指 ...

  2. margin负值的使用

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. [转载]C# 判断字符是否中文还是英文

    private static bool IsHanZi(string ch) { byte[] byte_len = System.Text.Encoding.Default.GetBytes(ch) ...

  4. BT5之网络配置

    输入ifconfig命令,可以查看当前IP地址设置情况.查看路由表的命令(用来检查默认网关是否设置正确):netstat -r 一.让BT5自动获取IP地址 自动获取IP地址,使用dhclient命令 ...

  5. DataTable转换List<T>集合的方法

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

  6. ZOJ 3603 Draw Something Cheat

    点我看题目 题意 : 给你n个字符串,让你找出在每个字符串中出现的字母,按字典序输出来. 思路 :一开始想差了,以为记录下每个字符出现次数,然后找次数大于1的,可是我忘了可能在一个字符串中有AA,而另 ...

  7. What's this?(js)

    What's this? 由于运行期绑定的特性,JavaScript 中的 this 含义非常多,它可以是全局对象.当前对象或者任意对象,这完全取决于函数的调用方式 随着函数使用场合的不同,this的 ...

  8. ANDROID_MARS学习笔记_S01原始版_023_MP3PLAYER004_同步显示歌词

    一.流程分析 1.点击播放按钮,会根据lrc名调用LrcProcessor的process()分析歌词文件,得到时间队列和歌词队列 2.new一个hander,把时间队列和歌词队列传给自定义的线程类U ...

  9. xml解析代码示例

    List<Entry> list = new ArrayList<>(); Entry entry = null; try { int eventType = response ...

  10. Android 国际化字符串资源,各语言目录表及从字符串资源文件读字符方法

    字符串国际化 只要在 res 目录下 建对应语言的 values 目录即可. res下values是所有资源(包括字符串资源)的默认目录,如果没有特指资源目录或找不到某资源时,就用它. 如values ...