【python_selenium】 執行selenium-谷歌時報錯:Web 驅動程式異常: Message: 'chromedriver' executable needs to be in PATH
阿新 • • 發佈:2022-04-07
問題:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
chrome_obj = webdriver.Chrome() # 開啟Google瀏覽器 chrome_obj.get("https://www.baidu.com") # 開啟 網址
解決方案:
1、查詢谷歌瀏覽器版本:位址列輸入 chrome://version/
2、下載谷歌驅動: http://chromedriver.storage.googleapis.com/index.html
3、解壓縮檔案,將 chromedriver.exe 放入目錄
方法①:驅動檔案解壓,放在selenium安裝目錄/selenium\webdriver\chrome下 【未解決】
方法②:驅動檔案解壓,放在python安裝目錄\Python38-32\Scripts目錄下 【問題解決】
拓展
把driver放在python的Scripts路徑下,同時把script路徑加入環境變數
谷歌驅動【chromedriver】下載地址:http://chromedriver.storage.googleapis.com/index.html
火狐歷史版本下載地址: http://ftp.mozilla.org/pub/firefox/releases/
火狐驅動【geckodriver】下載地址: https://github.com/mozilla/geckodriver/releases
IE瀏覽器驅動【IEdriver】下載地址: 【未實踐】
http://dl.pconline.com.cn/download/771640-1.html
http://www.nuget.org/packages/Selenium.WebDriver.IEDriver/