日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

selenium firefox驱动_Python3+selenium配置常见报错解决方案

發布時間:2024/7/5 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 selenium firefox驱动_Python3+selenium配置常见报错解决方案 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

第一個報錯問題

'geckodriver' executable needs to be in PATH

1.1如果啟動瀏覽器過程中報如下錯誤:

Traceback?(most?recent?call?last):
File?"",?line?1,?in?<module>
File?"D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py",?line?145,?in?__init__
self.service.start()
File?"D:\test\python3\lib\site-packages\selenium\webdriver\common\service.py",?line?81,?in?start
os.path.basename(self.path),?self.start_error_message)
selenium.common.exceptions.WebDriverException:?Message:?'geckodriver'?executable?needs?to?be?in?PATH.

1.2這個是因為最新的selenium3.0啟動firefox需要geckodriver.exe這個驅動文件。

1.3下載之后,配置到環境變量path下(可以直接放python根目錄)

第二個報錯問題

Expected browser binary location, but unable to find binary in default location

1.1如果啟動瀏覽器過程中報如下錯誤:

Traceback?(most?recent?call?last):
File?"",?line?1,?in?<module>
File?"D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py",?line?155,?in?__init__
keep_alive=True)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?92,?in?__init__
self.start_session(desired_capabilities,?browser_profile)

File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?179,?in?start_session
response?=?self.execute(Command.NEW_SESSION,?capabilities)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?238,?in?execute
self.error_handler.check_response(response)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py",?line?193,?in?check_response
raise?exception_class(message,?screen,?stacktrace)
selenium.common.exceptions.WebDriverException:?Message:?Expected?browser?binary?location,?but?unable?to?find?binary?in?default?location,
no?'moz:firefoxOptions.binary'?capability?provided,?and?no?binary?flag?set?on?the?command?line.

1.2這個是因為firefox.exe這個文件也需要配置到環境變量path下

1.3這個路徑就是安裝完firefox后,找到firefox.exe這個文件的地址,加到path下

第三個報錯問題

Unsupported Marionette protocol version 2, required 3

1.1如果啟動瀏覽器過程中出現如下錯誤:

Traceback?(most?recent?call?last):
File?"",?line?1,?in?<module>

File?"D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py",?line?155,?in?__init__
keep_alive=True)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?92,?in?__init__
self.start_session(desired_capabilities,?browser_profile)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?179,?in?start_session
response?=?self.execute(Command.NEW_SESSION,?capabilities)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py",?line?238,?in?execute
self.error_handler.check_response(response)
File?"D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py",?line?193,?in?check_response

raise?exception_class(message,?screen,?stacktrace)
selenium.common.exceptions.WebDriverException:?Message:?Unsupported?Marionette?protocol?version?2,?required?3

1.2這個錯誤原因是firefox版本過低了,最新的selenium3.0版本支持firefox47以上的版本,升級版本就可以了

第四個報錯問題

WebDriverException: Message: newSession

1.1Traceback (most recent call last):

File?“D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”,?line?170,?in?init
keep_alive=True)
File?“D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”,?line?156,?in?init
self.start_session(capabilities,?browser_profile)
File?“D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”,?line?245,?in?start_session
response?=?self.execute(Command.NEW_SESSION,?parameters)
File?“D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”,?line?314,?in?execute
self.error_handler.check_response(response)
File?“D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\errorhandler.py”,?line?242,?in?check_response
raise?exception_class(message,?screen,?stacktrace)
selenium.common.exceptions.WebDriverException:?Message:?newSession

1.2下載最新的geckodriver.exe 然后把它放到python的安裝目錄下


本文版權歸作者心安-lucky所有,歡迎轉載,但未經作者同意必須保留此段聲明,否則保留追究法律責任的權利。

專注當下 用心生活微信號:gml02030107喜歡就長按圖片掃碼關注吧

作者@心安-lucky

編輯@心安-lucky

圖片@心安-lucky

總結

以上是生活随笔為你收集整理的selenium firefox驱动_Python3+selenium配置常见报错解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。