简体   繁体   English

尝试使用 selenium 打开网页但出现错误

[英]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.

相关问题 尝试使用selenium和python登录网页时出错 - Error trying to login to webpage using selenium with python 尝试使用 selenium 废弃网站但出现此错误 - Trying to scrap the website using selenium but getting this error 尝试使用 selenium 登录我大学的网页时,我不断收到错误消息 NoSuchElementException - I keep getting the error message NoSuchElementException when trying to use selenium to log into my university's webpage 如何在 python 上使用 selenium 打开一个新网页? - How to open a new webpage using selenium on python? 尝试在Python中使用Selenium启动网页 - Trying to launch a webpage using Selenium in Python 尝试使用 selenium 单击网页上的元素 - Trying to click an element on a webpage using selenium 尝试使用机械化打开网页时出错 - Error when trying to open a webpage with mechanize 尝试 selenium 打开谷歌时出现名称错误 - name error while trying selenium to open google 尝试通过使用 Selenium 和 Python 的框架和 Javascript 的网页登录时出现 ERR_TOO_MANY_REDIRECTS 错误 - ERR_TOO_MANY_REDIRECTS error while trying to login through a webpage that uses frames and Javascript using Selenium and Python 如何解决启动 Chrome 时出现“获取默认适配器失败”错误并尝试使用 Selenium 使用 ChromeDriver 访问网页 - How to solve 'Getting Default Adapter failed' error when launching Chrome and try to access a webpage using the ChromeDriver using Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM