我的utils.py文件

#!/usr/bin/env python
#-*- coding:utf8 -*- __version__ = '0.1' import sys
reload(sys)
sys.setdefaultencoding('utf8') from robot.api import logger
import urllib2, json, re, os, random
import xml.dom.minidom class Utils():
def read_xml(self, arg):
u'''测试数据存储文件,接收节点name,返回text。\n
例:
| Read Xml | email |
'''
path = os.getcwd()+"\\data\\test_data.xml"
dom = xml.dom.minidom.parse(path)
root = dom.documentElement
texts = root.getElementsByTagName(arg)
options = root.getElementsByTagName('switch')
if int(options[0].firstChild.data) == 1:
text = texts[0]
return text.firstChild.data
elif (int(options[0].firstChild.data) == 2):
text = texts[1]
return text.firstChild.data if __name__ == '__main__':
# get = GetReset()
pass

我的__init__.py文件

#  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 utils import Utils    
from reply import Reply __version__ = '0.1' class UtilsLibrary(Utils, Reply): ROBOT_LIBRARY_SCOPE = 'GLOBAL'

在Python27\Lib\site-packages目录下新建UtilsLibrary文件夹,两个文件丢到里面。

然后进入cmd先编译这两个文件,生成.pyc

python -m __init__.py utils.py

  

启动robot framework ride,添加library,如图:

黑色说明添加成功。

按F5,如图:

robot framework用python扩展编写自定义library的更多相关文章

  1. Robot Framework通过Python SMTP进行email收发测试。

    工作中需要对发送的邮件进行过滤,方法基本属于ACL控制,即查看“源/目的”邮件地址,邮件标题,邮件正文,邮件附件等进行过滤. 所以需要先模拟一下用Python能否达到邮件Client,Server的功 ...

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

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

  3. [Robot Framework] 通过Robot Remote Server调用White Library测试WPF开发的桌面产品

    参考 : https://github.com/jatalahd/WhiteRobotLibrary 通过此源代码编译WhiteRobotLibrary.dll,然后把高亮标记的这5个dll全部拷贝到 ...

  4. Robot Framework + Selenium library + IEDriver环境搭建

    转载:https://www.cnblogs.com/Ming8006/p/4998492.html#c.d 目录: 1 安装文件准备2 Robot框架结构3 环境搭建  3.1 安装Python  ...

  5. Robot Framework测试框架学习笔记

    一.Robot Framework框架简介         Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...

  6. Robot Framework操作

    Robot Framework 介绍 RobotFramework是一款基于python的开源自动化测试框架,遵守Apache License 2.0协议,在此协议下所有人都可以免费开发和使用.因为R ...

  7. 2小时入门Robot Framework

    1.介绍 1.1.介绍Robot Robot Framework是一个基于关键字驱动的自动化测试框架.通过该框架,测试人员可使用python封装关键字,并在非代码环境下使用关键字构建可被执行的测试用例 ...

  8. Robot Framework简介

    概述 Robot Framework是一个通用的关键字驱动自动化测试框架.测试用例以HTML,纯文本或TSV(制表符分隔的一系列值)文件存储. 通过测试库中实现的关键字驱动被测软件.Robot Fra ...

  9. Robot Framework 使用1-环境配置及简单网站兼容性测试(转)

    0.Robot Framework 简介 Robot Framework 是一个通用的自动化测试框架,主要用于“验收测试”和“验收测试驱动开发(ATDD)” (会其它文章中会详细介绍ATDD).它使用 ...

随机推荐

  1. [LeetCode235]Lowest Common Ancestor of a Binary Search Tree

    题目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in th ...

  2. Service Manager流程,派BC_REPLY,唤醒FregServer流程,返回BR_TRANSACTION_COMPLETE,睡眠等待proc->wait

    本文參考<Android系统源代码情景分析>,作者罗升阳 一.service manager代码:        -/Android/frameworks/base/cmd/service ...

  3. iOS_动态插入或删除行

    终于效果图: 分MVC三层设计;自己定义的Cell有两种;一种是MainCell,由ModelArr提供数据源;还有一种是插入的cell,由代码创建,而且由另外一个数组供状态数据 数据源部分: wat ...

  4. MongoDB CRUD 基础知识

    建立一个良好的发展环境 环境win8 x64,下载并安装省略.经mongodb 的bin文件夹增加windows的path中,为以后使用方便. c盘新建存储目录:c:/data/db 执行服务:WIN ...

  5. java IdentityHashMap 与HashMap

    这两个map的主要区别在于,比较key值什么时候: IdentityHashMap我觉得当k1 == k2 时刻key值一样的 HaspMap觉得k1 == null ? k2 == null:k1. ...

  6. 每天的学习经验:SharePoint 2013 定义自己添加的产品清单。Callout菜单项、文档关注、SharePoint服务机端对象模型查询

    前言: 前一段时间一直都比較忙.没有什么时间进行总结,刚好节前项目上线.同一时候趁着放假能够好好的对之前遇到的一些问题进行总结. 主要内容有使用SharePoint服务端对象模型进行查询.为Share ...

  7. SIGPIPE并产生一个信号处理

    阅读TCP某物,知道server并关闭sockfd当写两次,会产生SIGPIPE信号,假如不治疗,默认将挂起server 弄个小样本试验: #include <unistd.h> #inc ...

  8. iOS如何兼容的应用程序32位系统和64Bit系统

    苹果发布iPhone5S时刻,64应用程序位去了眼前.当时我看到苹果公布的官方数据iOS7.x的SDK支撑64位应用程序.而内置的应用程序已经64位置. 我记得自己刚刚接触电脑时还有16位的系统,指针 ...

  9. android可扩展自己的定义,运动图像裁剪框

    在实际项目中,常常要制作一个简易的图像裁剪功能,即获取一张图片.并用一个遮罩层选择目标范围并截取保存的功能.例如以下图所看到的: 在此分享下该自己定义视图的制作过程. 需求说明 整一个视图包括一个透明 ...

  10. Python脚本传參和Python中调用mysqldump

    Python脚本传參和Python中调用mysqldump<pre name="code" class="python">#coding=utf-8 ...