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).它使用 ...
随机推荐
- Best Time to Buy and Sell Stock I,II,III [leetcode]
Best Time to Buy and Sell Stock I 你只能一个操作:维修preMin拍摄前最少发生值 代码例如以下: int maxProfit(vector<int> & ...
- Hosting WCF Service
之前在博客几个实例DemoWCF服务寄宿到控制到应用程序中,这篇来总结一下,经常使用的几种宿主的方式. 1.Self-Hosting 一个WCF服务可以寄宿在控制台应用程序或者WinForms app ...
- flashfxp3.41中文版注册码:(适合最新版本)
推荐(尚未被封的 Realkey) FLASHFXPvACq2ssbvAAAAAC1W7cJKQTzmx77zmqJICvA7d3WnU tWNXdrp8YuERRFdIvXfOPbcpABkVix2 ...
- Discuz 楼主帖子采集
try { ; i < ; i++) { var html = GetHtmls("http://bbs.fobshanghai.com/viewthread.php?tid=3885 ...
- 什么是Cyclomatic Complexity(圈复杂度)?
Campwood Software SourceMonitor Version 3.5 The freeware program SourceMonitor lets you see inside y ...
- QrcodeWithLogo
package com.qrcode; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import ...
- IOS使用Jenkins持续集成
本文详细介绍了开发过程,提高效率进行IOS-Jenkins持续集成. 第二http://blog.csdn.net/monkey_cool/article/details/43270885 背景 平时 ...
- 【java基础】==与equals()方法比较
1.八种基本类型 只有"=="方法进行判断是否相等,比较的是基本数据类型的值,没有equals()方法 2.Java类库中的类 "=="比较的是对象的句柄,即内 ...
- jQuery Mobile发展新闻阅读器,适应iphone和android打电话
程序猿是很不赖,你知道. 我们经常新浪,腾讯.雅虎等各大网站看到上述新闻.他们还推出了自己的移动新闻阅读器.今天,我自己用的jQuery Mobile 为了实现这一功能,.图像大小上传限制的大小250 ...
- Bash多个配置文件通常用于
Login shells阅读下面的启动文件: 文件 内容 /etc/profile 对全部用户开放的全局配置文件 ~/.bash_profile 某个用户个人的启动文件,能用作个人的全局设置 ~/.b ...