我写了这个简单的代码:
from selenium import webdriver
webdriver.Chrome().get('www.google.co.in')但我发现了一个错误:
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\WebAutomation\venv\Automation.py", line 2, in <module>
webdriver.Chrome().get('www.google.co.in')
File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 89, in __init__
self.service.start()
File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home谁来帮帮我。我是初学者,请详细解释/指导(我不知道复杂的概念)
发布于 2022-05-28 14:32:32
您将需要额外的Selenium-ChromeDriver.exe!最后一行错误告诉您。
selenium.common.exceptions.WebDriverException:消息:“
驱动程序”可执行文件需要在路径中。请参阅https://chromedriver.chromium.org/home
驱动程序本身将从您的程序启动,并将保存您的程序和浏览器铬本身之间的绑定。
driver.exe可以很容易地放置在程序启动路径中(我建议在第一步中这样做),也可以放置到任何您想要的位置,但是您必须定义driver.exe路径的特殊变量。
您可以在这个链接后面获得driver.exe:
主页:https://chromedriver.chromium.org/getting-started
下载网页:https://chromedriver.chromium.org/downloads
请确保您的浏览器版本与驱动程序版本匹配.
https://stackoverflow.com/questions/72400294
复制相似问题