splinter安装
来源:互联网 发布:vim python插件 编辑:程序博客网 时间:2024/06/08 03:34
Splinter:Splinter is an open source tool for testing web applications using Python. It lets you automate browser actions, such as visiting URLs and interacting with their items.
1027 pip install splinter
1028 cd opt1029 git clone git://github.com/cobrateam/splinter.git
1030 ll
1031 cd splinter
1032 ll
1033 python setuppy.install
1034 python setup.py install
1035 python
1036 pip install splinter[zope.testbrowser]
1037 cd /
1039 cd opt
1040 wget https://pypi.python.org/pypi/lxml/3.4.0#downloads
1041 ll
1042 wget https://pypi.python.org/pypi/lxml/3.4.0#downloads
1043 wget https://pypi.python.org/packages/source/l/lxml/lxml-3.4.0.tar.gz#md5=bc90cc4e4ee04e1f8290ae0f70e34eea
lxml是python的一个html/xml解析并建立dom的库(dom文档对象模型)
1046 tar -zxvf lxml-3.4.0.tar.gz
1047 cd lxml-3.4.01048 ll
1049 python setup.py install
vi splinter.py
#!/usr/bin/python
# SPLint output colorizer
#
# This script runs SPLint with a given set of arguments and colorizes the
# output to improve readability.
import sys
import os
import re
# Colors for printing
colors = {
'red' : '\033[31m',
'green' : '\033[32m',
'yellow' : '\033[33m',
'blue' : '\033[34m',
'magenta' : '\033[35m',
'cyan' : '\033[36m',
'white' : '\033[37m'
}
# This is where the compiled regexes will get stored soon
regexes = {}
# Hook to colorize the Splint title line. This is useful, because it helps you
# find the beginning of last run's output.
def title_hook(line):
print colors["green"]
x = "#" * len(line)
print x
print line
print x + "\033[0m"
# Hook to colorize Splint's function names
def funcname_hook(line):
fre = re.compile("(.*\(in function )(.*)(\).*)")
obj = fre.match(line)
if (obj is not None):
print obj.group(1) + colors["magenta"] + obj.group(2) + "\033[0m" + obj.group(3)
# Hook to colorize error messages
def error_hook(line):
print colors["red"] + line + "\033[0m"
# Hook to colorize explainatory text
def explaination_hook(line):
print colors["blue"] + line + "\033[0m"
def info_hook(line):
print colors["cyan"] + line + "\033[0m"
hooks = {
'title' : title_hook,
'funcname' : funcname_hook,
'error' : error_hook,
'expl' : explaination_hook,
'info' : info_hook
}
# Uncompiled regexes. This is what we look for in Splint's output and then
# call hook functions (see @hooks below...) to do whatever we want with this
# line
regex_uncompiled = {
'title' : "Splint \d\..*",
'funcname' : ".*\(in function .*\).*",
'error' : "\s{4,4}\S.*",
'expl' : "\s{2,2}\S.*",
'info' : "Command Line:.*"
}
### START OF SCRIPT ###
# Compile the regexes
for reg in regex_uncompiled.keys():
regexes[reg] = re.compile(regex_uncompiled[reg])
# build cmd line
cmdline = ""
for param in sys.argv[1:]:
cmdline += (" " + param)
print "Executing: ", cmdline
# Output will be redirected
# XXX: I'd prefer to read the output directly into this script?
cmdline += " >&_splint.out"
# execute splint
os.system(cmdline)
# read output and remove temp file
f = file("_splint.out")
output = f.readlines()
os.system("rm _splint.out")
# process output
for line in output:
# erase trailing newline
l = line.strip("\n")
seen = 0
# try to match this line with a regex
for name in regexes:
if regexes[name].match(l):
seen = 1
hooks[name](l)
break
# if no regex matched, simply print
if seen == 0:
print l
cp 至/usr/bin 下,执行 from splinter import Browser,报错 ImportError:cannot import name Browser
yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel运行后依然报错Type "help", "copyright", "credits" or "license" for more information.>>> from splinter.browser import BrowserTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/splinter-0.6.0-py2.6.egg/splinter/__init__.py", line 6, in <module> from splinter.browser import Browser File "/usr/lib/python2.6/site-packages/splinter-0.6.0-py2.6.egg/splinter/browser.py", line 12, in <module> from splinter.driver.webdriver.phantomjs import WebDriver as PhantomJSWebDriver File "/usr/lib/python2.6/site-packages/splinter-0.6.0-py2.6.egg/splinter/driver/webdriver/phantomjs.py", line 1, in <module> from selenium.webdriver import PhantomJS, DesiredCapabilitiesImportError: cannot import name PhantomJS
- splinter安装
- python安装splinter
- splinter安装与入门
- Splinter
- python splinter安装与使用
- Python splinter安装与使用
- python setuptools splinter安装报错UnicodeDecodeError
- 测试工具----Splinter安装环境的配置
- Windows中Splinter的安装和使用
- Python自动化脚本splinter框架chromedriver的安装
- Splinter(Gtalk)的免费网络电话
- splinter 学习笔记
- splinter 学习笔记
- splinter学习笔记
- Chrome WebDriver(splinter)
- 使用splinter进行爆破
- splinter的使用讲解
- python splinter 火车票抢购
- Hibernate get和load区别
- WinForm(C#)中跨线程访问控件的解决方法
- Video/Motion Segmentation Dataset and Benchmark
- JS处理JSON字符串
- UIScrollView加到导航控制器注意加一句话
- splinter安装
- 浏览器的内部对象
- 实例分析jdom和dom4j的使用和区别
- SQL Server 语句大全
- 第七周项目三 求三个数中的最大值
- MVC过滤器使用案例:统一处理异常顺道精简代码
- 第七周项目三(2)三个数最大值
- JAVAWeb 计时器问题
- java接口和多继承