自動化測試Web應用的Python工具:splinter
splinter是一個用于測試Web應用的Python工具,它可以自動操作瀏覽器,如訪問網址,并與網頁中的項目進行交互。提供簡單的元素查找,表單提交和其它瀏覽器動作。
簡單代碼
from splinter import Browserwith 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"</pre> <div class="highlight-python"></div>
</div>
特性
- API簡單
- 多個webdrivers (chrome webdriver, firefox webdriver, phantomjs webdriver, zopetestbrowser, remote webdriver)
- 支持css 和 xpath 選擇器
- 支持 iframe 和alert
- 可以執行javascript
- 支持ajax 和 async javascript
項目主頁:http://www.baiduhome.net/lib/view/home/1419217353125
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!