核心內容:
一、Splinter的簡介
二、Splinter的安裝
三、檢驗Splinter是否安裝成功
四、Geckodriver驅動的安裝
五、Splinter的操做示例python
(一)Splinter的簡介
Splinter是一個使用Python開發的開源Web應用測試工具,它能夠幫你實現自動瀏覽站點和與其進行交互。我也是由於工做需求的緣由才找到這個軟件的。git
(二)Splinter的安裝
注意:前提必需要安裝好python,否則是不對的。
一、下載的網址:https://pypi.python.org/pypi/splinter/,目前最新版本是0.7.5,測試平臺是window7 64位(這個不太肯定),Windows用的也是tar.gz。 github
二、先將下載好的Splinter解壓縮到指定的文件夾當中,在這裏爲D:\Splinter。 web
三、打開cmd黑窗口,並經過相應命令進入到Splinter解壓縮以後所在的目錄,在這裏即爲:D:\Splinter\splinter-0.7.5。 chrome
四、隨後輸入命令python setup.py build,以下所示:django
D:\Splinter\splinter-0.7.5>python setup.py build
running build
running build_py
creating build
creating build\lib
creating build\lib\splinter
copying splinter\browser.py -> build\lib\splinter
copying splinter\cookie_manager.py -> build\lib\splinter
copying splinter\element_list.py -> build\lib\splinter
copying splinter\exceptions.py -> build\lib\splinter
copying splinter\meta.py -> build\lib\splinter
copying splinter\utils.py -> build\lib\splinter
copying splinter\__init__.py -> build\lib\splinter
creating build\lib\splinter\driver
copying splinter\driver\djangoclient.py -> build\lib\splinter\driver
copying splinter\driver\element_present.py -> build\lib\splinter\driver
copying splinter\driver\flaskclient.py -> build\lib\splinter\driver
copying splinter\driver\lxmldriver.py -> build\lib\splinter\driver
copying splinter\driver\zopetestbrowser.py -> build\lib\splinter\driver
copying splinter\driver\__init__.py -> build\lib\splinter\driver
creating build\lib\splinter\request_handler
copying splinter\request_handler\status_code.py -> build\lib\splinter\request_handler
copying splinter\request_handler\__init__.py -> build\lib\splinter\request_handler
creating build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\chrome.py -> build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\cookie_manager.py -> build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\firefox.py -> build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\phantomjs.py -> build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\remote.py -> build\lib\splinter\driver\webdriver
copying splinter\driver\webdriver\__init__.py -> build\lib\splinter\driver\webdriver
running egg_info
writing requirements to splinter.egg-info\requires.txt
writing splinter.egg-info\PKG-INFO
writing top-level names to splinter.egg-info\top_level.txt
writing dependency_links to splinter.egg-info\dependency_links.txt
reading manifest file 'splinter.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tests'
writing manifest file 'splinter.egg-info\SOURCES.txt'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
五、上一步命令執行成功後,接着執行命令python setup.py install,以下所示:flask
D:\Splinter\splinter-0.7.5>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to splinter.egg-info\requires.txt
writing splinter.egg-info\PKG-INFO
writing top-level names to splinter.egg-info\top_level.txt
writing dependency_links to splinter.egg-info\dependency_links.txt
reading manifest file 'splinter.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tests'
writing manifest file 'splinter.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build\bdist.win32
creating build\bdist.win32\egg
creating build\bdist.win32\egg\splinter
copying build\lib\splinter\browser.py -> build\bdist.win32\egg\splinter
copying build\lib\splinter\cookie_manager.py -> build\bdist.win32\egg\splinter
creating build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\driver\djangoclient.py -> build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\driver\element_present.py -> build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\driver\flaskclient.py -> build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\driver\lxmldriver.py -> build\bdist.win32\egg\splinter\driver
creating build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\chrome.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\cookie_manager.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\firefox.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\phantomjs.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\remote.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\webdriver\__init__.py -> build\bdist.win32\egg\splinter\driver\webdriver
copying build\lib\splinter\driver\zopetestbrowser.py -> build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\driver\__init__.py -> build\bdist.win32\egg\splinter\driver
copying build\lib\splinter\element_list.py -> build\bdist.win32\egg\splinter
copying build\lib\splinter\exceptions.py -> build\bdist.win32\egg\splinter
copying build\lib\splinter\meta.py -> build\bdist.win32\egg\splinter
creating build\bdist.win32\egg\splinter\request_handler
copying build\lib\splinter\request_handler\status_code.py -> build\bdist.win32\egg\splinter\request_handler
copying build\lib\splinter\request_handler\__init__.py -> build\bdist.win32\egg\splinter\request_handler
copying build\lib\splinter\utils.py -> build\bdist.win32\egg\splinter
copying build\lib\splinter\__init__.py -> build\bdist.win32\egg\splinter
byte-compiling build\bdist.win32\egg\splinter\browser.py to browser.pyc
byte-compiling build\bdist.win32\egg\splinter\cookie_manager.py to cookie_manager.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\djangoclient.py to djangoclient.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\element_present.py to element_present.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\flaskclient.py to flaskclient.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\lxmldriver.py to lxmldriver.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\chrome.py to chrome.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\cookie_manager.py to cookie_manager.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\firefox.py to firefox.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\phantomjs.py to phantomjs.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\remote.py to remote.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\webdriver\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\zopetestbrowser.py to zopetestbrowser.pyc
byte-compiling build\bdist.win32\egg\splinter\driver\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\splinter\element_list.py to element_list.pyc
byte-compiling build\bdist.win32\egg\splinter\exceptions.py to exceptions.pyc
byte-compiling build\bdist.win32\egg\splinter\meta.py to meta.pyc
byte-compiling build\bdist.win32\egg\splinter\request_handler\status_code.py to status_code.pyc
byte-compiling build\bdist.win32\egg\splinter\request_handler\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\splinter\utils.py to utils.pyc
byte-compiling build\bdist.win32\egg\splinter\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying splinter.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying splinter.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying splinter.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying splinter.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO
copying splinter.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist\splinter-0.7.5-py2.7.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing splinter-0.7.5-py2.7.egg
Copying splinter-0.7.5-py2.7.egg to d:\python27\lib\site-packages
Adding splinter 0.7.5 to easy-install.pth filecookie
Installed d:\python27\lib\site-packages\splinter-0.7.5-py2.7.egg
Processing dependencies for splinter==0.7.5
Searching for selenium>=2.53.6
Reading https://pypi.python.org/simple/selenium/
Downloading https://pypi.python.org/packages/d4/0c/8429b64f9035b8db9a30c39a90fa07a460ebc4bd3639b868a1081b80a868/selenium-3.3.1.tar.gz#
Best match: selenium 3.3.1
Processing selenium-3.3.1.tar.gz
Writing c:\users\hp\appdata\local\temp\easy_install-aaaxb3\selenium-3.3.1\setup.cfg
Running selenium-3.3.1\setup.py -q bdist_egg --dist-dir c:\users\hp\appdata\local\temp\easy_install-aaaxb3\selenium-3.3.1\egg-dist-tmp
warning: no files found matching 'selenium\selenium.py'
warning: no files found matching 'LICENSE'
creating d:\python27\lib\site-packages\selenium-3.3.1-py2.7.egg
Extracting selenium-3.3.1-py2.7.egg to d:\python27\lib\site-packages
Adding selenium 3.3.1 to easy-install.pth fileapp
Installed d:\python27\lib\site-packages\selenium-3.3.1-py2.7.egg
Finished processing dependencies for splinter==0.7.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(三)檢驗Splinter是否安裝成功
在python模式下輸入命令:from splinter.browser import Browser,若是沒有報錯,則說明安裝成功! 工具
(四)Geckodriver驅動的安裝
問題由來,以下圖所示:
從報出的異常能夠看出,火狐Firefox缺乏驅動Geckodriver,下面咱們來安裝這個Geckodriver驅動插件:
適用版本:Firefox 48版本以及以上
下載地址:https://github.com/mozilla/geckodriver/releases,在連接的最下面,咱們選擇:1.92 MBgeckodriver-v0.15.0-win64.zip進行下載。
放置的位置:在Windows當中,將解壓縮以後的Geckodriver放置到python安裝的根目錄(即與python.exe 同一目錄)當中,此時Splinter安裝完畢。
原文:https://blog.csdn.net/a2011480169/article/details/67141540