天天看點

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

本文已收錄github:https://github.com/BigDataScholar/TheKingOfBigData,裡面有大資料高頻考點,Java一線大廠面試題資源,上百本免費電子書籍,作者親繪大資料生态圈思維導圖…持續更新,歡迎star!

        今天在做selenium測試的時候,可能是很久沒用了,直接報了這個異常!

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        相信很多第一次學習selenium的同學們也對這個異常不陌生了,但具體該如何解決這個bug呢?

        主要的原因還是因為selenium模拟的用戶端對浏覽器的操作,但相應浏覽器的驅動版本不比對導緻的。

        為了解決這個問題,我們需要先了解我們目前浏覽器的版本。以小菌用的谷歌浏覽器為例。

        打開浏覽器,在位址欄輸入

chrome://version/

便可以檢視到谷歌目前的版本号

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        接着我們來到谷歌浏覽器驅動的下載下傳網址

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

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        我們再往下滑

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        選擇了一個版本最近的目錄輕按兩下進入

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        然後我們隻需要根據作業系統,選擇不同的zip下載下傳即可!

        下載下傳完我們解壓開,就是chromedriver.exe

        還差最後一步,隻需要把它放到下面兩個路徑下即可!

        一個是在C槽的路徑下,具體的位置:

C:\Program Files (x86)\Google\Chrome\Application

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        還有一個就是在你python安裝的目錄下,

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決

        然後回到項目中,成功運作!!!

        小夥伴們,你們的bug解決好了麼!

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘解決