??? 交流討論:歡迎加入我們一起學(xué)習(xí)!
?? 資源分享:耗時(shí)200+小時(shí)精選的「軟件測(cè)試」資料包
???教程推薦:火遍全網(wǎng)的《軟件測(cè)試》教程??
??歡迎點(diǎn)贊 ?? 收藏 ?留言 ?? 如有錯(cuò)誤敬請(qǐng)指正!
環(huán)境: win10 +
想要Python通過selenium操作瀏覽器搞些事情,就必須有兩個(gè)前提條件:
- 下載selenium模塊
- 安裝selenium的瀏覽器驅(qū)動(dòng) webdriver
selenium模塊下載
pip install selenium pip install -i https://pypi.doubanio.com/simple/ selenium pip install -i https://pypi.doubanio.com/simple/ selenium==3.141.0
瀏覽器驅(qū)下載
瀏覽器驅(qū)動(dòng)的安裝時(shí)新手階段遇到較多問題之一,因?yàn)榭蛇x擇的瀏覽器較多,我們先來聊聊各種場(chǎng)景的瀏覽器:
- 網(wǎng)頁瀏覽器,也就是我們現(xiàn)在經(jīng)常用到的瀏覽器,打開瀏覽器有個(gè)可視化的界面供我們操作,常見的有:
- Firefox
- Safari
- IE/edge
- Opera
- 無頭瀏覽器(Headless Browser),無頭,這里是說無界面的,這種瀏覽器的運(yùn)行是不可見的,selenium中常用的無頭瀏覽器有:
- PhantomJS無頭瀏覽器
- Google無頭瀏覽器
- Firefox無頭瀏覽器
關(guān)于無頭瀏覽器:無頭瀏覽器指的是沒有圖形用戶界面的瀏覽器。無頭瀏覽器在類似于流行網(wǎng)絡(luò)瀏覽器的環(huán)境中提供對(duì)網(wǎng)頁的自動(dòng)控制,但是通過命令行界面或使用網(wǎng)絡(luò)通信來執(zhí)行。 它們對(duì)于測(cè)試網(wǎng)頁特別有用,因?yàn)樗鼈兡軌蛳駷g覽器一樣呈現(xiàn)和理解超文本標(biāo)記語言,包括頁面布局、顏色、字體選擇以及JavaScript和AJAX的執(zhí)行等樣式元素,這些元素在使用其他測(cè)試方法時(shí)通常是不可用的。
無頭瀏覽器常用于:
- Web應(yīng)用程序中的測(cè)試自動(dòng)化。
- 拍攝網(wǎng)頁截圖
- 對(duì)JavaScript庫運(yùn)行自動(dòng)化測(cè)試
- 收集網(wǎng)站數(shù)據(jù)
- 自動(dòng)化網(wǎng)頁交互
使用無頭瀏覽器的優(yōu)勢(shì):
- 對(duì)于UI自動(dòng)化測(cè)試,少了真實(shí)瀏覽器加載css,js以及渲染頁面的工作。無頭測(cè)試要比真實(shí)瀏覽器快的多。
- 可以在無界面的服務(wù)器或CI上運(yùn)行測(cè)試,減少了外界的干擾,使自動(dòng)化測(cè)試更穩(wěn)定。
- 在一臺(tái)機(jī)器上可以模擬運(yùn)行多個(gè)無頭瀏覽器,方便進(jìn)行并發(fā)測(cè)試。
關(guān)于PhantomJS無頭瀏覽器:PhantomJS是一個(gè)可以用JavaScript編寫腳本的無頭web瀏覽器。它在Windows、macOS、Linux和FreeBSD上運(yùn)行。使用QtWebKit作為后端,它為各種web標(biāo)準(zhǔn)提供了快速的本地支持:DOM處理、CSS選擇器、JSON、Canvas和SVG。
另外,說一個(gè)比較悲痛的消息:PhantomJS暫停維護(hù)(可能的原因是內(nèi)部問題和外部壓力(Google和Firefox無頭帶來的壓力)),所以,我們現(xiàn)在使用PhantomJS的話,你會(huì)看到提示:
UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
閑話少敘,先來看具體怎么安裝和使用!
3|0網(wǎng)頁瀏覽器回到頂部
相對(duì)于無頭瀏覽器來說,網(wǎng)頁瀏覽器有以下優(yōu)勢(shì):
- 配置相對(duì)簡(jiǎn)單
- 執(zhí)行過程可視化,便于調(diào)試
- 模擬真實(shí)的用戶操作
3|1Chrome回到頂部
Chrome的驅(qū)動(dòng)下載地址:
- https://npm.taobao.org/mirrors/chromedriver
- http://chromedriver.storage.googleapis.com/index.html
這里以淘寶鏡像為例。
- 查看你的Chrome瀏覽器的版本。打開你的Chrome瀏覽器的
設(shè)置
?幫助
?關(guān)于Google Chrome(G)
,這里我的Chrome的版本是81.0.4044.129
2. 打開淘寶鏡像鏈接:https://npm.taobao.org/mirrors/chromedriver,如下圖,可以看到,有兩個(gè)81版本的驅(qū)動(dòng),我們選擇一個(gè)最貼近瀏覽器版本的驅(qū)動(dòng)版本81.0.4044.69
- 那我們選擇的對(duì)嗎?現(xiàn)在點(diǎn)擊
81.0.4044.69/
這個(gè)驅(qū)動(dòng)下載鏈接中,查看notes.txt
文件??梢钥吹剑?code>notes.txt文件中說了三件事,瀏覽器驅(qū)動(dòng)的版本、依賴瀏覽器的版本、該版本的驅(qū)動(dòng)解決了哪些問題。通過依賴的瀏覽器驅(qū)動(dòng)版本我們可以知道,這個(gè)就是我們想要的那個(gè)驅(qū)動(dòng)。
- 回到之前的驅(qū)動(dòng)下載頁面,根據(jù)系統(tǒng)選擇不同的安裝包,這里我選擇
chromedriver_win32.zip
。點(diǎn)擊鏈接立即下載到本地。
- 壓縮包內(nèi)就一個(gè)
chromedriver.exe
可執(zhí)行文件,將該文件移動(dòng)到Python的安裝目錄中的Scripts
目錄(因?yàn)樵撃夸浺呀?jīng)添加到了系統(tǒng)Path中,你移動(dòng)到別的目錄也行,只要將目錄添加到系統(tǒng)的Path中)
- 可以嘗試測(cè)試一下了:
from selenium import webdriver def foo(): """ 如果報(bào)如下錯(cuò)誤: selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 原因是在執(zhí)行時(shí),沒有在path中找到驅(qū)動(dòng),這里的解決辦法是實(shí)例化driver對(duì)象時(shí),添加executable_path參數(shù),引用驅(qū)動(dòng)的絕對(duì)路徑 """</span> <span class="hljs-comment"># driver = webdriver.Chrome(executable_path="C:\Python36\Scripts\chromedriver.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Chrome() driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() 原因是在執(zhí)行時(shí),沒有在path中找到驅(qū)動(dòng),這里的解決辦法是實(shí)例化driver對(duì)象時(shí),添加executable_path參數(shù),引用驅(qū)動(dòng)的絕對(duì)路徑 """</span> <span class="hljs-comment"># driver = webdriver.Chrome(executable_path="C:\Python36\Scripts\chromedriver.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Chrome() driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() if name == 'main': foo()
效果就是打開一個(gè)瀏覽器,然后代碼獲取了百度主頁的title,然后關(guān)閉瀏覽器。
3|2Firefox回到頂部
- 還是要先查看Firefox的瀏覽器版本,
設(shè)置
?幫助
?關(guān)于 Firefox
,可以看我的Firefox版本是74。
- 打開Firefox的驅(qū)動(dòng)下載地址:Releases · mozilla/geckodriver · GitHub,在最新的
v0.26.0
版本的描述中,推薦Firefox的版本≥60,而我們的Firefox版本正符合;下拉根據(jù)系統(tǒng)選擇不同的壓縮包,這里我選擇geckodriver-v0.26.0-win64.zip
。
- 下載到本地是一個(gè)
geckodriver.exe
可執(zhí)行文件,同樣的,你將該文件移動(dòng)到Python安裝目錄中的Scripts
目錄(跟Google的驅(qū)動(dòng)放一起,不會(huì)放的,參考Google驅(qū)動(dòng)的第5步)。
- 測(cè)試:
from selenium import webdriver def foo(): """ 如果報(bào)如下錯(cuò)誤: selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 原因是在執(zhí)行時(shí),沒有在path中找到驅(qū)動(dòng),這里的解決辦法是實(shí)例化driver對(duì)象時(shí),添加executable_path參數(shù),引用驅(qū)動(dòng)的絕對(duì)路徑 """ <span class="hljs-comment"># driver = webdriver.Firefox(executable_path="C:\Python36\Scripts\geckodriver.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Firefox() <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() <span class="hljs-comment"># driver = webdriver.Firefox(executable_path="C:\Python36\Scripts\geckodriver.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Firefox() <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() if name == 'main': foo()
這里在再補(bǔ)充一個(gè)錯(cuò)誤,我之前的Firefox的版本是最新版,但我本機(jī)運(yùn)行有問題,所以在使用selenium操作的時(shí)候,報(bào)了這個(gè)錯(cuò)誤:
selenium.common.exceptions.TimeoutException: Message: connection refused
經(jīng)過查詢是我的Firefox瀏覽器有問題,我就降級(jí)裝了個(gè)74版本的。但這只是個(gè)例。
3|3Safari回到頂部
首先保證你的Python和selenium模塊安裝完成:
# 使用brew命令安裝python3.7 brew install python3 # 安裝selenium模塊 pip3 install selenium==3.141.0
來看如何配置Safari。
從macOS El Capitan和Sierra上的Safari 10開始,每個(gè)版本的瀏覽器都包含WebDriver支持。要啟用支持:
Enable the Developer menu from Safari preferences # 從Safari首選項(xiàng)中啟用“開發(fā)人員”菜單 Check the Allow Remote Automation option from with the Develop menu # 從“開發(fā)”菜單中選中“允許遠(yuǎn)程自動(dòng)化”選項(xiàng)
?
然后,在首次啟動(dòng)之前,終端輸入:
/usr/bin/safaridriver -p 1337
然后按照提示輸入密碼,使webdriver獲得授權(quán)。
現(xiàn)在可以執(zhí)行測(cè)試了:
from selenium import webdriver def foo(): driver = webdriver.Safari() driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() driver = webdriver.Safari() driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() if name == 'main': foo()
如下報(bào)錯(cuò)是提示你沒有勾選
selenium.common.exceptions.SessionNotCreatedException: Message: Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.
意思是:必須在Safari的“開發(fā)”菜單中啟用“允許遠(yuǎn)程自動(dòng)化”選項(xiàng),才能通過WebDriver控制Safari。如果你之前設(shè)置了,這里以不會(huì)報(bào)錯(cuò)了。
3|4IE回到頂部
必要的配置
- 在
設(shè)置
?縮放
中,將比例調(diào)整為100%。 - 在
設(shè)置
?Internet 選項(xiàng)
?安全
選項(xiàng),如下圖,將四個(gè)選項(xiàng)都勾選啟用保護(hù)模式
。
3. 針對(duì)IE10和更高的版本,必須在IE選項(xiàng)設(shè)置中的高級(jí)頁中,取消增強(qiáng)保護(hù)模式。
重啟IE瀏覽器。
webdriver驅(qū)動(dòng)安裝
- 由于IE的webdriver驅(qū)動(dòng)依賴selenium模塊的版本,所以,我們先來查看selenium模塊的版本,這里我的selenium模塊的版本是
Version: 3.141.0
:
C:\Users\Anthony>pip36 show selenium WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly. Name: selenium Version: 3.141.0 Summary: Python bindings for Selenium Home-page: https://github.com/SeleniumHQ/selenium/ Author: UNKNOWN Author-email: UNKNOWN License: Apache 2.0 Location: c:\python36\lib\site-packages Requires: urllib3 Required-by: Appium-Python-Client
- 下載IE瀏覽器的webdriver驅(qū)動(dòng),訪問http://selenium-release.storage.googleapis.com/index.html定位到跟selenium版本一致的鏈接并且進(jìn)入該鏈接內(nèi)。
- 這里一定要選擇跟你的selenium版本一致的壓縮包;另外,我的系統(tǒng)是64位的,但這里我選擇32位的壓縮包,原因是據(jù)不可靠消息,32位相對(duì)于64位性能更好!
- 將
IEDriverServer.exe
可執(zhí)行文件拷貝到Python的安裝目錄中的Scripts
目錄內(nèi)。
- 現(xiàn)在,可以測(cè)試了。
from selenium import webdriver def foo(): """ 如果報(bào)如下錯(cuò)誤: selenium.common.exceptions.WebDriverException: Message: 'IEDriverServer.exe' executable needs to be in PATH. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver 原因是在執(zhí)行時(shí),沒有在 path中找到驅(qū)動(dòng),這里的解決辦法是實(shí)例化driver對(duì)象時(shí),添加executable_path參數(shù),引用驅(qū)動(dòng)的絕對(duì)路徑 """ <span class="hljs-comment"># driver = webdriver.Ie(executable_path="C:\Python36\Scripts\IEDriverServer.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Ie() <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> <span class="hljs-comment"># driver = webdriver.Firefox()</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() <span class="hljs-comment"># driver = webdriver.Ie(executable_path="C:\Python36\Scripts\IEDriverServer.exe") # 解決如上報(bào)錯(cuò)</span> driver = webdriver.Ie() <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> <span class="hljs-comment"># driver = webdriver.Firefox()</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() if name == 'main': foo()
4|0無頭瀏覽器回到頂部
我們?nèi)粘J褂脼g覽器的步驟為:?jiǎn)?dòng)瀏覽器、打開一個(gè)網(wǎng)頁、進(jìn)行交互。而無頭瀏覽器指的是我們使用腳本來執(zhí)行以上過程的瀏覽器,能模擬真實(shí)的瀏覽器使用場(chǎng)景。
有了無頭瀏覽器,我們就能做包括但不限于以下事情:
- 對(duì)網(wǎng)頁進(jìn)行截圖保存為圖片或 pdf。
- 抓取單頁應(yīng)用(SPA)執(zhí)行并渲染(解決傳統(tǒng) HTTP 爬蟲抓取單頁應(yīng)用難以處理異步請(qǐng)求的問題)。
- 做表單的自動(dòng)提交、UI的自動(dòng)化測(cè)試、模擬鍵盤輸入等。
- 用瀏覽器自帶的一些調(diào)試工具和性能分析工具幫助我們分析問題。
- 在最新的無頭瀏覽器環(huán)境里做測(cè)試、使用最新瀏覽器特性。
- 寫爬蟲做你想做的事情。
無頭瀏覽器很多,包括但不限于:
- PhantomJS, 基于 Webkit
- SlimerJS, 基于 Gecko
- HtmlUnit, 基于 Rhnio
- TrifleJS, 基于 Trident
- Splash, 基于 Webkit
這里我們簡(jiǎn)單來說,在selenium中使用無頭瀏覽器。
4|1PhantomJS回到頂部
PhantomJS是一個(gè)無界面的、可腳本編程的WebKit瀏覽器引擎,其快速,原生支持各種Web標(biāo)準(zhǔn): DOM 處理, CSS 選擇器, JSON, Canvas, 和 SVG。
- PhantomJS是一個(gè)基于webkit內(nèi)核、無界面的瀏覽器,即它就是一個(gè)瀏覽器,只是其內(nèi)的點(diǎn)擊、翻頁等人為相關(guān)操作需要程序設(shè)計(jì)實(shí)現(xiàn);
- PhantomJS提供Javascript API接口,可以通過編寫JS程序直接與webkit內(nèi)核交互;
- PhantomJS的應(yīng)用:無需瀏覽器的 Web 測(cè)試、網(wǎng)頁截屏、頁面訪問自動(dòng)化、網(wǎng)絡(luò)監(jiān)測(cè)。
官網(wǎng):PhantomJS - Scriptable Headless Browser
github:GitHub - ariya/phantomjs: Scriptable Headless Browser
下載安裝
- 打開下載鏈接:Download PhantomJS,根據(jù)自己的系統(tǒng)平臺(tái),下載相應(yīng)的包,我這里是Windows 64位系統(tǒng),所以,我選擇下載windows版本的,phantomjs-2.1.1版本下載地址:
- 將壓縮包解壓到?jīng)]有中文、空格的目錄,我這里解壓到Python的安裝目錄中的
Scripts
目錄。
- 將
phantomjs-2.1.1-windows
的bin目錄添加到系統(tǒng)path中。
- 測(cè)試。
from selenium import webdriver def foo(): """ 如果報(bào)如下錯(cuò)誤: selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 原因是在執(zhí)行時(shí),沒有在 path中找到驅(qū)動(dòng),這里的解決辦法是實(shí)例化driver對(duì)象時(shí),添加executable_path參數(shù),引用驅(qū)動(dòng)的絕對(duì)路徑 """ driver = webdriver.PhantomJS(executable_path=<span class="hljs-string">r"C:\Python36\Scripts\phantomjs-2.1.1-windows\bin\phantomjs.exe"</span>) <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() driver = webdriver.PhantomJS(executable_path=<span class="hljs-string">r"C:\Python36\Scripts\phantomjs-2.1.1-windows\bin\phantomjs.exe"</span>) <span class="hljs-comment"># 解決如上報(bào)錯(cuò)</span> driver.implicitly_wait(time_to_wait=<span class="hljs-number">10</span>) driver.get(<span class="hljs-string">'https://www.baidu.com'</span>) print(driver.title) <span class="hljs-comment"># 百度一下,你就知道</span> driver.quit() if name == 'main': foo()
之前說 PhantomJS 和新版的selenium已經(jīng)分手,所以你在使用的時(shí)候,會(huì)有這提示,注意,這是提示,不是報(bào)錯(cuò)!
解決辦法!要么視而不見,要么按照提示去使用Google或者Firefox的無頭瀏覽器吧。
4|2Google無頭回到頂部
自2017年中以來,Chrome用戶可以選擇以headless模式運(yùn)行瀏覽器(chrome 59.0)。此功能非常適合運(yùn)行前端瀏覽器測(cè)試,而無需在屏幕上顯示操作過程。在此之前,這主要是PhantomJS的領(lǐng)地,但Headless Chrome正在迅速取代這個(gè)由JavaScript驅(qū)動(dòng)的WebKit方法。Headless Chrome瀏覽器的測(cè)試運(yùn)行速度要快得多,而且行為上更像一個(gè)真正的瀏覽器,雖然我們的團(tuán)隊(duì)發(fā)現(xiàn)它比PhantomJS使用更多的內(nèi)存。有了這些優(yōu)勢(shì),用于前端測(cè)試的Headless Chrome很可能成為事實(shí)上的標(biāo)準(zhǔn)。
所以,我們來看Google無頭瀏覽器怎么玩的吧!畢竟這是以后無頭瀏覽器陣營(yíng)的扛把子!
說起來,Google的無頭瀏覽器配置倒也簡(jiǎn)單,只需要要在實(shí)例化driver對(duì)象的時(shí)候,添加參數(shù)即可。
from selenium import webdriver from selenium.webdriver.chrome.options import Options # 創(chuàng)建一個(gè)參數(shù)對(duì)象,用來控制chrome以無界面模式打開 chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') # 創(chuàng)建瀏覽器對(duì)象 driver = webdriver.Chrome(chrome_options=chrome_options) # driver = webdriver.Chrome() # 不加 chrome_options 參數(shù)就是正常的打開一個(gè)瀏覽器,進(jìn)行操作 driver.implicitly_wait(10) # 訪問URL driver.get('https://www.baidu.com') print(driver.title) # 百度一下,你就知道 driver.quit()
4|3Firefox無頭回到頂部
Google搞了無頭瀏覽器之后(2017年5月),小老弟Firefox也不甘落后,從 55.0 開始也支持了HEADLESS模式(2017年9月)。
配置也相當(dāng)?shù)暮?jiǎn)單。
from selenium import webdriver from selenium.webdriver.firefox.options import Options # 創(chuàng)建瀏覽器對(duì)象 options = Options() options.add_argument("-headless") driver = webdriver.Firefox(firefox_options=options) # driver = webdriver.Firefox() # # 不加 firefox_options 參數(shù)就是正常的打開一個(gè)瀏覽器,進(jìn)行操作 driver.implicitly_wait(10) # 訪問URL driver.get('https://www.baidu.com') print(driver.title) # 百度一下,你就知道 driver.quit()
不得不說,大廠就是大廠,Google和Firefox的聯(lián)手打壓下,再加上PhantomJS的內(nèi)部矛盾,導(dǎo)致在短短的幾個(gè)月后(2018年4月),PhantomJS的核心開發(fā)者團(tuán)隊(duì)宣布不再維護(hù)該項(xiàng)目,老大哥終將落幕了啊!
哦,忘了說了,據(jù)不可靠消息說:
- Google無頭相對(duì)于UI的瀏覽器節(jié)省30%左右的時(shí)間。
- Firefox無頭相對(duì)于UI的瀏覽器節(jié)省3%左右的時(shí)間。
這話不是我說的,是:http://www.suchcode.com/topic/592/WebDriver測(cè)試的無頭執(zhí)行 - Firefox瀏覽器。
哦,還有,phantomjs 都不維護(hù)了,還講它干嘛?那是因?yàn)槲覀兛梢栽诮鼐W(wǎng)頁長(zhǎng)圖的時(shí)候使用。暫時(shí)我還沒有找到使用Chrome和Firefox截長(zhǎng)圖的辦法!只能使用 phantomjs 了啊!
最后我邀請(qǐng)你進(jìn)入我們的【軟件測(cè)試學(xué)習(xí)交流群:785128166】, 大家可以一起探討交流軟件測(cè)試,共同學(xué)習(xí)軟件測(cè)試技術(shù)、面試等軟件測(cè)試方方面面,還會(huì)有免費(fèi)直播課,收獲更多測(cè)試技巧,我們一起進(jìn)階Python自動(dòng)化測(cè)試/測(cè)試開發(fā),走向高薪之路
作為一個(gè)軟件測(cè)試的過來人,我想盡自己最大的努力,幫助每一個(gè)伙伴都能順利找到工作。所以我整理了下面這份資源,現(xiàn)在免費(fèi)分享給大家,有需要的小伙伴可以關(guān)注【公眾號(hào):程序員二黑】自提!
文章來源:http://www.zghlxwxcb.cn/news/detail-858599.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-858599.html
到了這里,關(guān)于Web自動(dòng)化測(cè)試—webdriver的環(huán)境配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!