Python 自動化測試環境配置及入門示例(基於splinter)

基本環境

1、python

https://www.python.org/downloads/windows/

2、splinter

https://pypi.org/project/splinter/

3、firefox driver(geckodriver)

https://github.com/mozilla/geckodriver/releases

4、chrome driver

http://chromedriver.storage.googleapis.com/index.html

示例

from splinter import Browser

with Browser() as browser:
    url = "搜索引擎"
    browser.visit(url)
    browser.fill('q', 'splinter - python acceptance testing for web applications')

    button = browser.find_by_name('btnG')

    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"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章