[英]Trying to open a webpage using selenium but getting error
I wrote this simple code:我写了这个简单的代码:
from selenium import webdriver
webdriver.Chrome().get('www.google.co.in')
but I'm getting this error:但我收到此错误:
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
Someone please help me.有人请帮助我。 I'm a beginner, please explain/guide in detail (I don't know complex concepts)
我是初学者,请详细解释/指导(我不懂复杂的概念)
You will need additional the Selenium-Chrome-Driver.exe!您将需要额外的 Selenium-Chrome-Driver.exe! The last line of errors tells this to you.
最后一行错误告诉你这一点。
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要在 PATH 中。 Please see https://chromedriver.chromium.org/home
请参阅https://chromedriver.chromium.org/home
The driver itself will be started from your programm and will hold the binding between your program and the browser chrome itself.驱动程序本身将从您的程序启动,并将保持您的程序与浏览器 chrome 本身之间的绑定。
The driver.exe can be easily placed in the programm-startup-path (I recommend this for the first steps) or placed where ever you want, but than you must define the special variable of the PATH to the driver.exe. driver.exe 可以很容易地放在 programm-startup-path 中(我建议在第一步中这样做)或放置在您想要的任何位置,但是您必须将 PATH 的特殊变量定义到 driver.exe。
You can get the driver.exe behind this link:您可以在此链接后面获取 driver.exe:
Main page: https://chromedriver.chromium.org/getting-started主页: https ://chromedriver.chromium.org/getting-started
Download Page: https://chromedriver.chromium.org/downloads下载页面: https ://chromedriver.chromium.org/downloads
Please ensure, that your Browser-Version match to the driver-Version.请确保您的浏览器版本与驱动程序版本匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.