51Testing软件测试论坛

标题: 使用selenium+chrome+webdriver,驱动是出现异常 [打印本页]

作者: 测试积点老人    时间: 2021-11-29 09:28
标题: 使用selenium+chrome+webdriver,驱动是出现异常
第一次进行测试,用selenium控制打开chrome结果报错,不知道如何解决,请求解决办法

  1. >>> driver=webdriver.Chrome()
  2. Traceback (most recent call last):
  3.   File "C:\python3\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
  4.     self.process = subprocess.Popen(cmd, env=self.env,
  5.   File "C:\python3\lib\subprocess.py", line 832, in __init__
  6.     errread, errwrite) = self._get_handles(stdin, stdout, stderr)
  7.   File "C:\python3\lib\subprocess.py", line 1294, in _get_handles
  8.     c2pwrite = msvcrt.get_osfhandle(self._get_devnull())
  9.   File "C:\python3\lib\subprocess.py", line 1077, in _get_devnull
  10.     self._devnull = os.open(os.devnull, os.O_RDWR)
  11. FileNotFoundError: [Errno 2] No such file or directory: 'nul'
  12. During handling of the above exception, another exception occurred:
  13. Traceback (most recent call last):
  14.   File "<stdin>", line 1, in <module>
  15.   File "C:\python3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
  16.     super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  17.   File "C:\python3\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__
  18.     self.service.start()
  19.   File "C:\python3\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
  20.     raise WebDriverException(
  21. selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
复制代码



作者: 海海豚    时间: 2021-11-30 09:14
chromedriver需要放在正确的路径下
作者: qqq911    时间: 2021-11-30 10:20
添加下环境变量
作者: jingzizx    时间: 2021-11-30 17:33
配置




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2