# selenium使用Chrome时报错:
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
1、进入页面
https://sites.google.com/a/chromium.org/chromedriver/home

在这里插入图片描述
2、选择合适的Chrome版本下载

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
3、解压下的Chromedriver放到python安装的目录下,

在这里插入图片描述
4、运行测试
from selenium import webdriver # 从selenium导入webdriver
driver = webdriver.Chrome() # Optional argument, if not specified will search path.
driver.get('https://www.baidu.com') # 获取百度页面

在这里插入图片描述
可以了,之前测试了好几次,安装其他目录加到环境变量还是不行,后来放到python安装目录下就好了。