简体   繁体   English

selenium.common.exceptions.WebDriverException:消息:未知错误:无法创建 Chrome 进程

[英]selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process

I am working on a web application, and was attempting to run a basic test script with seleium, just to make sure my code was working我正在开发一个 Web 应用程序,并试图用 seleium 运行一个基本的测试脚本,以确保我的代码正常工作

from selenium import webdriver
import time
import os

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = os.getcwd()
driver = webdriver.Chrome(chrome_options=options, executable_path=r'./chromedriver')
driver.get('http://codepad.org')

I have the chromedriver in the current directory, and I think I am using the correct version of the chromedriver (75.0.3770.90).我在当前目录中有 chromedriver,我想我使用的是正确版本的 chromedriver (75.0.3770.90)。 The full error I am getting is:我得到的完整错误是:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    driver = webdriver.Chrome(options=options, executable_path=r'./chromedriver')
  File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process.

If anyone has any insight into a fix I could try that would be greatly appreciated!如果有人对修复有任何见解,我可以尝试,将不胜感激!

Remove/comment the below line.删除/注释以下行。

options.binary_location = os.getcwd()

As the binary is not located in the current working directory you are getting this error message.由于二进制文件不在当前工作目录中,因此您会收到此错误消息。

binary_location is the location where your chrome.exe is located. binary_location 是 chrome.exe 所在的位置。

And make sure you have the chromedriver in the same folder you have this test located.并确保 chromedriver 位于此测试所在的同一文件夹中。 Otherwise your script will fail with below error message.否则您的脚本将失败并显示以下错误消息。

selenium.common.exceptions.WebDriverException: Message: 'chromedriver` executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

The value binary_location must be an .exe file which specify the chrome.exe you want to run.binary_location必须是指定要运行的chrome.exe的 .exe 文件。

So this code works for me:所以这段代码对我有用:

chrome_options = Options()
chrome_options.binary_location = '****\\chrome.exe'
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver\\chromedriver.exe"),   options=chrome_options)

Hope it helps you希望对你有帮助

暂无
暂无

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

相关问题 selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用 ChromeDriver Chrome Selenium 创建 Chrome 进程错误 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process error with ChromeDriver Chrome Selenium selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用带有Selenium Python的ChromeDriver Chrome创建Chrome进程 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process with ChromeDriver Chrome with Selenium Python selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法以Selenium和RaspberryPi上的Chrome启动 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start with Selenium and Chrome on RaspberryPi Selenium.common.exceptions.WebDriverException:消息:未知错误:没有 chrome 二进制文件 - Selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:使用ChromeDriver Chrome和Selenium异常退出 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium 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:消息:未知错误:在ubuntu上执行selenium python脚本时,chrome无法启动 - selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start while executing selenium python script on ubuntu TDD-Django(部署)错误:selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:异常退出 - TDD-Django(deploy) Error : selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:异常退出。 Dockerize Flask 应用程序 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. Dockerize Flask Application Selenium 在 Mac 上给出“selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary” - Selenium gives "selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary" on Mac
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM