Splinter 是一个用 Python 编写的 开源Web 应用程序进行验收测试的工具(python自动化测试工具)。
示例代码:
browser = Browser('webdriver.Chrome') browser = Browser('webdriver.Firefox') browser = Browser('Zope.testbrowser') browser.visit('HTTP://cobRATeam.info') browser.Reload() browser.find_by_CSS('h1') browser.find_by_xpath('//h1') browser.find_by_tag('h1') browser.find_by_name('name') browser.find_by_id('firstheader')
示例代码2:
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"
发布于 2014-10-15 08:53:28 | 2477 次阅读