简体   繁体   English

selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要在 PATH 中

[英]selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

在此处输入图片说明 I am trying to automate my web application using the python and selenium, I am facing the below issue.我正在尝试使用 python 和 selenium 自动化我的 Web 应用程序,我面临以下问题。

Environment - Mac/Python/Selenium IDE - PyCharm环境 - Mac/Python/Selenium IDE - PyCharm

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. selenium.common.exceptions.WebDriverException: 消息:'chromedriver' 可执行文件需要在 PATH 中。 Please see https://sites.google.com/a/chromium.org/chromedriver/home请参阅https://sites.google.com/a/chromium.org/chromedriver/home

Please help me resolve this issue.请帮我解决这个问题。

Yes.是的。 because you haven't pass the Chrome binary which required by Selenium to drive your Chrome browser.因为您还没有通过 Selenium 所需的 Chrome 二进制文件来驱动您的 Chrome 浏览器。

You need to download binary as per your OS from below URL :-您需要根据您的操作系统从以下 URL 下载二进制文件:-

https://chromedriver.storage.googleapis.com/index.html?path=2.32/ https://chromedriver.storage.googleapis.com/index.html?path=2.32/

Use below code :-使用以下代码:-

import os
from selenium import webdriver

chromedriver = "/Users/adam/Downloads/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")

Change the path of chromedriver in above code更改上面代码中chromedriver的路径

OR或者

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': /Users/adam/Downloads/chromedriver"}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path="/Users/adam/Downloads/chromedriver")
driver.get('http://google.com/')

OR或者

Alternatively you can use a direct path to the chromedriver like this:或者,您可以像这样使用 chromedriver 的直接路径:

 driver = webdriver.Chrome('/path/to/chromedriver')

Source:来源:

Running Selenium WebDriver python bindings in chrome 在 chrome 中运行 Selenium WebDriver python 绑定

You need to download the chromedriver binary from ChromeDriver Download page and place it anywhere within your system.您需要从ChromeDriver Download页面下载chromedriver二进制文件并将其放置在系统中的任何位置。 While you initiate the WebDriver instance you need to mention the absolute path of the ChromeDriver binary.当您启动WebDriver实例时,您需要提及ChromeDriver二进制文件的绝对路径。

On my Windows 8 system the following code block works perfect:在我的Windows 8系统上,以下代码块完美运行:

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)

At firsts you need to download chrome driver from https://sites.google.com/a/chromium.org/chromedriver/downloads then unarchive it.首先,您需要从https://sites.google.com/a/chromium.org/chromedriver/downloads下载 chrome 驱动程序,然后将其解压缩。 then add this file to params of enviroments.然后将此文件添加到环境参数中。 And then write driver = webdriver.Chrome('C:\\YourPathofChromeDriver\\chromedriver.exe')然后写 driver = webdriver.Chrome('C:\\YourPathofChromeDriver\\chromedriver.exe')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为 Windows - selenium.common.exceptions.WebDriverException 安装 Chromedriver:消息:“chromedriver.exe”可执行文件需要在 PATH 中 - Installing Chromedriver for Windows - selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要在无头 Chrome 的 PATH 错误中 - selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome Gitlab CI 出现错误 selenium.common.exceptions.WebDriverException:消息:当我运行我的简单 pro 时,'chromedriver' 可执行文件需要在 PATH 中 - Gitlab CI got error selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH when I running my simple pro selenium.common.exceptions.WebDriverException:消息:“ geckodriver”可执行文件必须与GeckoDriver Selenium Firefox一起放入PATH - selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH with GeckoDriver Selenium Firefox selenium.common.exceptions.WebDriverException:消息:'firefox' 可执行文件需要在 GeckoDriver Firefox Selenium 和 Python 的 PATH 中 - selenium.common.exceptions.WebDriverException: Message: 'firefox' executable needs to be in PATH with GeckoDriver Firefox Selenium and Python selenium.common.exceptions.WebDriverException:消息:“库”可执行文件可能对 ChromeDriver 具有错误的权限 - selenium.common.exceptions.WebDriverException: Message: 'library' executable may have wrong permissions for ChromeDriver selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出 - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited WebDriverException:WebDriverException:消息:“chromedriver”可执行文件需要在 PATH 中 - WebDriverException: WebDriverException: Message: 'chromedriver' executable needs to be in PATH selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python selenium.common.exceptions.WebDriverException: 消息:无法通过 Selenium Python 使用 ChromeDriver Chrome 连接到服务错误 - selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service error using ChromeDriver Chrome through Selenium Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM