Selenium學習之: Exception: Failed to find firefox binary. You can set it by specifying the ······

問題描述:

在Python中使用代碼打開FireFox瀏覽器,在使用selenium的時候出現瞭如下錯誤:

Exception: Failed to find firefox binary. You can set it by specifying the ······

簡單查了一下,是selenium版本(2.48)過低

 

解決方案:

1. 打開cmd,輸入pip show selenium,查看selenuim版本,若爲2
2. 執行pip uninstall selenium,把原來低版本的selenuim卸載掉
3. 之後再執行pip install selenium,自動安裝最新版本的selenuim3
自己電腦安裝版本:

Firefox-version:54.0.0

geckodriver-version:0.18

selenuim-version:3.141.0

geckodriver下載地址:https://github.com/mozilla/geckodriver/releases

下載後解壓到當前目錄, 把解壓的geckodriver.exe複製到python文件夾下:

 同時,chromedriver.exe加入進來,同時python環境也要設置好

OK, 這樣selenium可以正常使用了,運行python代碼,執行成功