简体   繁体   English

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

This is my code script:这是我的代码脚本:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\hadi\\AppData\\Local\\Google\\Chrome\\User Data") #Path to your chrome profile
w = webdriver.Chrome(executable_path="E:\Python\chromedriver.exe", chrome_options=options)
w.get("https://www.facebook.com")

and on running this script i'm getting this error:在运行此脚本时,我收到此错误:

Traceback (most recent call last):
  File "E:/Python/MoosaBhai/TestoTes.py", line 6, in <module>
    w = webdriver.Chrome(executable_path="E:\\Python\\chromedriver.exe", chrome_options=options)
  File "C:\Users\hadi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\hadi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\hadi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\hadi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:\Users\hadi\AppData\Local\Programs\Python\Python36-32\lib\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: Chrome failed to start: crashed
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 x86_64)

I've edited my executeable path to chromedriver but when i run the script my chrome driver opens but after that stuck for 2-3minutes and then crashes with the above following error.我已经编辑了 chromedriver 的可执行路径,但是当我运行脚本时,我的 chrome 驱动程序打开了,但之后卡住了 2-3 分钟,然后因上述以下错误而崩溃。

Thumb rule经验法则

A common cause for Chrome to crash during startup is running Chrome as root user ( administrator ) on Linux. Chrome 在启动期间崩溃的一个常见原因是在 Linux 上以root用户( administrator )身份运行 Chrome。 While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged.虽然可以通过在创建 WebDriver 会话时传递--no-sandbox标志来解决此问题,但这种配置不受支持且非常不鼓励。 You need to configure your environment to run Chrome as a regular user instead.您需要将环境配置为以普通用户身份运行 Chrome。


As per your code trials seems you are trying to access a Chrome Profile so you can use the following solution:根据您的代码试验,您似乎正在尝试访问Chrome 配置文件,因此您可以使用以下解决方案:

  • Code Block:代码块:

     from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument("user-data-dir=C:\\\\path\\\\to\\\\your\\\\profile\\\\Google\\\\Chrome\\\\User Data\\\\Profile 2") driver = webdriver.Chrome(executable_path=r'C:\\path\\to\\chromedriver.exe', chrome_options=options) driver.get("https://www.google.co.in")
  • Here you can find a detailed discussion in How to open a Chrome Profile through Python在这里您可以找到如何通过 Python 打开 Chrome 配置文件中的详细讨论

暂无
暂无

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

相关问题 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:消息:未知错误:无法使用带有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:消息:未知错误:无法使用 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:消息:未知错误: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:消息:未知错误:在ubuntu上执行selenium python脚本时,chrome无法启动 - selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start while executing selenium python script on ubuntu 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 Selenium.common.exceptions.WebDriverException:消息:未知错误:没有 chrome 二进制文件 - Selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary 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.common.exceptions.WebDriverException:消息:未知错误:无法创建 Chrome 进程 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM