在使用pycharm运行项目时,提示如下所示错误:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

 

解决方法:

1.先查看自己浏览器的版本

 

 2.再去下载该版本对应的ChromeDriver驱动

下载地址:http://chromedriver.storage.googleapis.com/index.html

如果没有完全对应的版本,下载一个相近版本的驱动就可以了

 

 

3.下载后解压到python安装的路径下,并加上如下代码

from selenium import webdriver
chrome_drive = r"C:\Users\Administrator\AppData\Local\Programs\Python\Python37\chromedriver.exe"
self.dr = webdriver.Chrome(executable_path = chrome_drive)

 

这样再次运行就可以成功了

 

posted on 2019-09-12 17:06  1348204588  阅读(3454)  评论(0编辑  收藏  举报