tags: 錯誤故障, WebDriver, Selenium, Python
在 Python 下引用 Selenium 包開發時,剛開始測試 WebDriver 的功能直接就甩出了一個錯誤消息然后就中斷了,錯誤消息:WebDriverException: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
搜索並嘗試一番后,順利解決。方法如下:
- 安裝 selenium 的 python 包之后,還要安裝瀏覽器 driver
我用的是 Chrome,以此為例:
a. 下載 ChromeDriver。其它瀏覽器參見官網說明
b. 復制chromedrive
文件到 Google Chrome 程序目錄下。各操作系統里的位置路徑可以參考官方Wiki - Python 代碼里創建 webdriver 對象時傳遞
chromedrive
路徑
chromedriver = "/Applications/Google Chrome.app/Contents/MacOS/chromedriver"
browser = webdriver.Chrome(chromedriver)```
---
相關:[Python + Selenium 開發的准備工作](http://www.cnblogs.com/buchiany/p/6399688.html)
_[正文結束]_
_[更新記錄]_
2016-12-16, 初建筆記