robot framework用python扩展编写自定义library
我的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的更多相关文章
- Robot Framework通过Python SMTP进行email收发测试。
工作中需要对发送的邮件进行过滤,方法基本属于ACL控制,即查看“源/目的”邮件地址,邮件标题,邮件正文,邮件附件等进行过滤. 所以需要先模拟一下用Python能否达到邮件Client,Server的功 ...
- Robot Framework自动化测试框架核心指南-如何使用Java编写自定义的RobotFramework Lib
如何使用Java编写自定义的RobotFramework Lib 本文包括2个章节 1. Robot Frdamwork中如何调用java Lib库 2.使用 java编写自定义的Lib 本文作者为: ...
- [Robot Framework] 通过Robot Remote Server调用White Library测试WPF开发的桌面产品
参考 : https://github.com/jatalahd/WhiteRobotLibrary 通过此源代码编译WhiteRobotLibrary.dll,然后把高亮标记的这5个dll全部拷贝到 ...
- Robot Framework + Selenium library + IEDriver环境搭建
转载:https://www.cnblogs.com/Ming8006/p/4998492.html#c.d 目录: 1 安装文件准备2 Robot框架结构3 环境搭建 3.1 安装Python ...
- Robot Framework测试框架学习笔记
一.Robot Framework框架简介 Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...
- Robot Framework操作
Robot Framework 介绍 RobotFramework是一款基于python的开源自动化测试框架,遵守Apache License 2.0协议,在此协议下所有人都可以免费开发和使用.因为R ...
- 2小时入门Robot Framework
1.介绍 1.1.介绍Robot Robot Framework是一个基于关键字驱动的自动化测试框架.通过该框架,测试人员可使用python封装关键字,并在非代码环境下使用关键字构建可被执行的测试用例 ...
- Robot Framework简介
概述 Robot Framework是一个通用的关键字驱动自动化测试框架.测试用例以HTML,纯文本或TSV(制表符分隔的一系列值)文件存储. 通过测试库中实现的关键字驱动被测软件.Robot Fra ...
- Robot Framework 使用1-环境配置及简单网站兼容性测试(转)
0.Robot Framework 简介 Robot Framework 是一个通用的自动化测试框架,主要用于“验收测试”和“验收测试驱动开发(ATDD)” (会其它文章中会详细介绍ATDD).它使用 ...
随机推荐
- 深入浅出JMS(一)——JMS简要
假设手机只能实时通话.没有邮件和短信功能发生?一个电话回来.只是没有足够的时间去连接.然后传递这款手机的信息肯定是不接受. 么不能先将信息存下来.当用户须要查看信息的时候再去获得信息呢?伴随着这个疑惑 ...
- [LeetCode234]Palindrome Linked List
题目: Given a singly linked list, determine if it is a palindrome. 判断一个单链表是不是回文 思路: 1.遍历整个链表,将链表每个节点的值 ...
- 源代码版本控制工具TortoiseSVN,AnkhSVN最新版本下载地址
TortoiseSVN http://tortoisesvn.net/downloads.html 页面下部有中文语言补丁 AnkhSVN https://ankhsvn.open.collab.ne ...
- mybatis 并发问题解决,参考hibernate
时候操作同一账户就是典型的样例. 比方A.B操作员同一时候读取一剩余金额为1000元的账户,A操作员为该账户添加100元.B操作员同一时候为该账户减去 50元.A先提交.B后提交. 最后实际账户剩余金 ...
- uitextField单词的方法和抖动的限制
这种方法还可以找到在线. 如下面的详细信息: .h文件 #import <UIKit/UIKit.h> @interface UITextField (LimitLength) /** * ...
- 原产地政策,jsonp跨域
一.同源策略 同源策略(Same origin policy)是一种约定,它是浏览器最核心也最主要的安全功能,假设缺少了同源策略,则浏览器的正常功能可能都会受到影响.能够 ...
- 股票作手回忆录Digest(转)
记住,驱动股市的不是理智.逻辑或纯经济因素,驱动股市的是从来不会改变的人的本性.它不会改变,因为它是我们的本性.[4] 在华尔街或在股票投机中,没有什么新的东西.过去发生的事情在将来会一而再,再而三地 ...
- 自己写CPU第九阶段(3)——加载存储指令说明2(swl、swr)
我们会继续上传新书<q=%E8%87%AA%E5%B7%B1%E5%8A%A8%E6%89%8B%E5%86%99CPU&ie=utf-8&src=se_lighten_quot ...
- LVM pvcreate,vgcreate,lvcreate,mkfs
首先介绍LVM的几个概念: 1. 物理卷Physical volume (PV):可以在上面建立卷组的媒介,可以是硬盘分区,也可以是硬盘本身或者回环文件(loopback file).物理卷包 ...
- 【Java】实现一个根据日期判断星座程序的编写
思路 直接根据月份做索引,然后根据日期边界判断是本月的星座还是上月的. 算法 private static String getAstro(int month, int day) { String[] ...