Python splinter 環境搭建

2022-03-22 04:40:38 字數 1686 閱讀 9941

今天無意間看到了splinter。

splinter是乙個使用python開發的開源web應用測試工具。它可以幫你實現自動瀏覽站點和與其進行互動。

splinter對已有的自動化工具(如:selenium、phantomjs和zope.testbrowser)進行抽象,形成乙個全新的上層應用api,它使為web應用編寫自動化測試指令碼變的更容易。

編輯splinter0.7.2依賴以下包:

selenium(版本》=2.44.0)

django(版本》=1.5.8,<1.7)

flask(版本》=0.10)

lxml(版本》=2.3.6)

zope.testbrowser(版本》=4.0.4)

cssselect

from splinter import

browser

with browser() as browser:

#visit url

url = "

搜尋引擎

"browser.visit(url)

browser.fill('q

', '')

#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

"

使用splinter填充乙個form的字段如下:

browser.fill('

username

', '

janedoe

')

而使用selenium需要:

elem = browser.find_element.by_name('

username')

elem.send_keys(

'janedoe

')

執行命令 

效果如下:

原環套原環

今天在除錯兄弟的程式的時候發現了乙個問題,就是在組合資料的時候,有些時候可以成功,有些時候失敗,感覺十分奇怪。功能大概是這樣的,就是在一棵樹上掛資料,所有的節點都可以有資料,不只是葉子的,在組合資料的時候,可以從任意節點取資料,但是不能是重複的資料。資料可能出現的情況如圖a b c所示,圖a是沒有干...

單鏈表的環入口,環大小,解環

1.單鏈表是否有環 使用快慢指標,都從head出發,慢指標一次一步,快指標一次兩步,如果兩個指標相遇,說明鍊錶有環,否則,快指標為null或其next為null,到達末尾節點 function hascircle head return fast null fast.next null 2.單鏈錶環...

有環鏈表的環起點

用兩個指標,乙個快指標一次走兩步,乙個慢指標一次走一步。快慢指標可以重合表示鍊錶有環,此時距離環起點的距離和起點距離環起點的距離相等。include bits stdc h using namespace std struct list list beginofcircle list p1,list...