python執行時提示WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
selenium:ChromeDriver executable needs to be available in path
安裝
詳細描述:想用chrome瀏覽器來執行測試用例,按照官方文件http://code.google.com/p/selenium/wiki/ChromeDriver 的步驟操作後還是報WebDriverException: Message: 'ChromeDriver executable needs to be available in path的錯,配了系統環境變數重啟後也沒用。
問題解決:最後在stackoverflow上找到答案,原答案地址:
用下面這種方法設環境變數就
import os
from selenium import webdriver
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")
driver.quit()
2.我相信很多人會去手寫python指令碼
請大家注意呼叫瀏覽器首字母要大寫。。。(今天差點弄死我),如:Firefox,Chrome,Ie
3.注意得把IEDriverServer跟chromedriver放到對應瀏覽器的安裝目錄下
配置瀏覽器的環境變數Path:如
Chrome:C:\Users\wyx\AppData\Local\Google\Chrome\Application
4.在python的安裝目錄下也放IEDriverServer,chromedriver