Splinter是一个基于Python语言的测试网络应用的工具,简化了搜索元素、表单动作和其他的浏览器动作。
特性
- 具有简单的API
- 多个webdriver(chrome webdriver, firefox webdriver, phantomjs webdriver, zopetestbrowser, remote webdriver)
- css和xpath选择器
- 支持iframe和alert
- 可执行javascript
- 支持ajax
示例
from splinter import Browser
with Browser() as browser:
# Visit URL
url = "http://www.google.com"
browser.visit(url)
browser.fill('q', 'splinter - python acceptance testing for web applications')
# Find and click the 'search' button
button = browser.find_by_name('btnG')
# Interact with elements
button.click()
if browser.is_text_present('splinter.cobrateam.info'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"
官网: http://splinter.cobrateam.info/
github主页: https://github.com/cobrateam/splinter