无法运行测试脚本。Python测试

无法运行测试脚本。Python测试,python,selenium,pycharm,chrome-web-driver,Python,Selenium,Pycharm,Chrome Web Driver,我可以运行脚本进行自动测试 这是剧本 from selenium import webdriver PATH = "Z:\PyProjects\venv\Scripts\chromedriver.exe" driver = webdriver.Chrome(PATH) driver.get("https://google.com/") Z:\PyProjects\venv\Scripts\python.exe Z:/PyProjects/test.py Traceback (mos

我可以运行脚本进行自动测试

这是剧本

    from selenium import webdriver
PATH = "Z:\PyProjects\venv\Scripts\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://google.com/")
 Z:\PyProjects\venv\Scripts\python.exe Z:/PyProjects/test.py
Traceback (most recent call last):
  File "Z:\PyProjects\venv\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 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] unable to find the file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Z:/PyProjects/test.py", line 3, in <module>
    driver = webdriver.Chrome(PATH)
  File "Z:\PyProjects\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "Z:\PyProjects\venv\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
这就是我在运行脚本后遇到的错误

    from selenium import webdriver
PATH = "Z:\PyProjects\venv\Scripts\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://google.com/")
 Z:\PyProjects\venv\Scripts\python.exe Z:/PyProjects/test.py
Traceback (most recent call last):
  File "Z:\PyProjects\venv\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 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] unable to find the file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Z:/PyProjects/test.py", line 3, in <module>
    driver = webdriver.Chrome(PATH)
  File "Z:\PyProjects\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "Z:\PyProjects\venv\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
Z:\PyProjects\venv\Scripts\python.exe Z:/PyProjects/test.py
回溯(最近一次呼叫最后一次):
文件“Z:\PyProjects\venv\lib\site packages\selenium\webdriver\common\service.py”,第72行,在开始处
self.process=subprocess.Popen(cmd,env=self.env,
文件“C:\Python38\lib\subprocess.py”,第854行,在\uuu init中__
self.\u execute\u child(参数、可执行文件、预执行文件、关闭文件、,
文件“C:\Python38\lib\subprocess.py”,第1307行,在执行子进程中
hp、ht、pid、tid=\u winapi.CreateProcess(可执行文件、参数、,
FileNotFoundError:[WinError 2]找不到该文件
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“Z:/PyProjects/test.py”,第3行,在
driver=webdriver.Chrome(路径)
文件“Z:\PyProjects\venv\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第73行,在\uuu init中__
self.service.start()
文件“Z:\PyProjects\venv\lib\site packages\selenium\webdriver\common\service.py”,第81行,在开始处
引发WebDriverException(
selenium.common.exceptions.WebDriverException:消息:“chromedriver.exe”可执行文件需要位于路径中。请参阅https://sites.google.com/a/chromium.org/chromedriver/home
进程已完成,退出代码为1