Splinter是一個使用Python開發的開源Web套用測試工具。它可以幫你實現自動瀏覽站點和與其進行互動。
基本介紹
- 外文名:Splinter
簡介
依賴包
代碼示例
from splinter import Browserwith Browser() as browser: # Visit URL url = "搜尋引擎" 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.readthedocs.org'): print "Yes, the official website was found!" else: print "No, it wasn't found... We need to improve our SEO techniques"
browser.fill('username', 'janedoe')
elem = browser.find_element.by_name('username')elem.send_keys('janedoe')