驱动版本ok,python中遇到“selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ ”的解决方法

一、问题现象

运行testDemo.py,报

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

驱动版本ok,python中遇到“selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ ”的解决方法_第1张图片

详情信息:
驱动版本ok,python中遇到“selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ ”的解决方法_第2张图片
C:\Python38\python.exe
E:/PycharmProjects/autotest_hyrobot/cases/baidu/testDemo.py Traceback
(most recent call last): File
“C:\Python38\lib\site-packages\selenium\webdriver\common\service.py”,
line 72, in start
self.process = subprocess.Popen(cmd, env=self.env, File “C:\Python38\lib\subprocess.py”, line 804, in init
errread, errwrite) = self._get_handles(stdin, stdout, stderr) File “C:\Python38\lib\subprocess.py”, line 1169, in _get_handles
c2pwrite = msvcrt.get_osfhandle(self._get_devnull()) File “C:\Python38\lib\subprocess.py”, line 952, in _get_devnull
self._devnull = os.open(os.devnull, os.O_RDWR) FileNotFoundError: [Errno 2] No such file or directory: ‘nul’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
“E:/PycharmProjects/autotest_hyrobot/cases/baidu/testDemo.py”, line 5,
in
d = webdriver.Chrome(executable_path=\ File “C:\Python38\lib\site-packages\selenium\webdriver\chrome\webdriver.py”,
line 73, in init
self.service.start() File “C:\Python38\lib\site-packages\selenium\webdriver\common\service.py”,
line 81, in start
raise WebDriverException( selenium.common.exceptions.WebDriverException: Message:
‘chromedriver.exe’ executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home

Process finished with exit code 1

二:testDemo.py内容

from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
time.sleep(3)
driver.quit()

三、解决方法

背景:浏览器驱动版本与浏览器版本一致,驱动放在python安装目录下的,chrome路径、python路径均已加入环境变量path中且通过cmd确认路径均有效(确认方法:1、在cmd中输入chrome可以打开chrome浏览器;2、在cmd中输入chromedriver显示驱动信息)。
驱动版本ok,python中遇到“selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ ”的解决方法_第3张图片
解决方法:未解决。。。(IE也是同样的问题)

四、其他

Firefor浏览器(版本为81.0.1)ok,使用浏览器版本和驱动链接如下:

链接: https://pan.baidu.com/s/1V6nzSlpVUpC0qS0wdcfttg 提取码: 9rmx

你可能感兴趣的:(问题及解决方法,python)