我正在使用python和selenium,并从这个网站下载了用于我的windows计算机的chromedriver: http://chromedriver.storage.googleapis.com/index.html?path=2.15/
下载压缩文件后,我将压缩文件解压缩到我的下载文件夹中。然后我把可执行二进制文件(C:\Users\michael\Downloads\chromedriver_win32)的路径放到环境变量“path”中。
然而,当我运行以下代码:
from selenium import webdriver
driver = webdriver.Chrome()
... 我一直得到以下错误消息:
WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver
但是-如上所述-可执行文件在路径中(!)…这是怎么回事?
适用于Linux和OSX
步骤1:下载chromedriver
# You can find more recent/older versions at http://chromedriver.storage.googleapis.com/
# Also make sure to pick the right driver, based on your Operating System
wget http://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip
对于debian: wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
步骤2:将chromedriver添加到/usr/local/bin目录
unzip chromedriver_mac64.zip
sudo mv chromedriver /usr/local/bin
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver
您现在应该可以运行了
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://localhost:8000')
没有任何问题