#python #selenium #selenium-webdriver
Вопрос:
Я только что установил и узнал об автоматизации. А потом, когда я захочу запустить этот код:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
есть такая ошибка, как эта строка :
$ C:/Users/HELLO/AppData/Local/Programs/Python/Python39/python.exe d:/Lain-lain/belajarSele.py
Traceback (most recent call last):
File "C:UsersHELLOAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdrivercommonservice.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:UsersHELLOAppDataLocalProgramsPythonPython39libsubprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UsersHELLOAppDataLocalProgramsPythonPython39libsubprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Во время обработки вышеуказанного исключения произошло еще одно исключение:
Traceback (most recent call last):
File "d:Lain-lainbelajarSele.py", line 3, in <module>
driver = webdriver.Chrome()
File "C:UsersHELLOAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverchromewebdriver.py", line 73, in __init__
self.service.start()
File "C:UsersHELLOAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdrivercommonservice.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Что мне делать?
Комментарии:
1. Привет. Вы проверили, что у вас есть правильный путь для драйвера chrome? Попробуй это
webdriver.Chrome(path where you saved your chrome driver)
2. Спасибо за ответ, это работает.
Ответ №1:
Вам нужно скачать chromedriver
отсюда
и после загрузки вы должны определить в своем коде следующее :
driver = webdriver.Chrome("C:/Users/*****/Downloads/chromedriver_win32/chromedriver.exe")