selenium使用報錯「selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs

安裝了python3,使用pip安裝了selenium,可是在使用時,報了「selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.」python

網上查了一下解決辦法,此處作下記錄:git

緣由:使用pip安裝selenium,默認安裝的是最新版本的selenium,使用pip list查了一下個人selenium版本,是3.4.2的,firefox版本,是43.0.1的,selenium 3.x開始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而2.x是executable_path="wires"github

方法一:能夠卸載現有的selenium,安裝指定的2.X版本的selenium,這個辦法沒有試,由於就是本着selenium3來的,不打算降版本;web

方法二:下載geckodriver.exeui

  1. 下載地址:https://github.com/mozilla/geckodriver/releases,根據本身的電腦,下載的win64位的;
  2. 在firefox的安裝目錄下,解壓geckodriver,而後將該路徑添加到path環境變量下,不報這個錯了;
  3. 可是,報了一個新的錯「selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities」;
  4. 繼續網上查,緣由是,我下載的geckodriver是V0.16.1版本的,這個版本和selenium3.4.2不兼容,須要使用deckdriverV0.15的版本;
  5. 從新下載了deckodriverV0.15的版本,ok了,不報這個錯了,可是,又報了一個新的錯「selenium.common.exceptions.WebDriverException: Message: Unsupported Marionette protocol version 2, required 3;
  6. 繼續往上查緣由,說是firefox版本過低了,須要升級到最新版,ok,更新firefox,問題解決。
相關文章
相關標籤/搜索