运行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
详情信息:
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/homeProcess finished with exit code 1
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显示驱动信息)。
解决方法:未解决。。。(IE也是同样的问题)
Firefor浏览器(版本为81.0.1)ok,使用浏览器版本和驱动链接如下:
链接: https://pan.baidu.com/s/1V6nzSlpVUpC0qS0wdcfttg 提取码: 9rmx