<legend id='Ka0v9'><style id='Ka0v9'><dir id='Ka0v9'><q id='Ka0v9'></q></dir></style></legend>

  • <tfoot id='Ka0v9'></tfoot>
    <i id='Ka0v9'><tr id='Ka0v9'><dt id='Ka0v9'><q id='Ka0v9'><span id='Ka0v9'><b id='Ka0v9'><form id='Ka0v9'><ins id='Ka0v9'></ins><ul id='Ka0v9'></ul><sub id='Ka0v9'></sub></form><legend id='Ka0v9'></legend><bdo id='Ka0v9'><pre id='Ka0v9'><center id='Ka0v9'></center></pre></bdo></b><th id='Ka0v9'></th></span></q></dt></tr></i><div id='Ka0v9'><tfoot id='Ka0v9'></tfoot><dl id='Ka0v9'><fieldset id='Ka0v9'></fieldset></dl></div>
  • <small id='Ka0v9'></small><noframes id='Ka0v9'>

      <bdo id='Ka0v9'></bdo><ul id='Ka0v9'></ul>

      1. selenium.common.exceptions.WebDriverException:消息:未知错误

        时间:2023-10-08

            • <small id='FPumN'></small><noframes id='FPumN'>

              • <bdo id='FPumN'></bdo><ul id='FPumN'></ul>
                <legend id='FPumN'><style id='FPumN'><dir id='FPumN'><q id='FPumN'></q></dir></style></legend>

                  <tfoot id='FPumN'></tfoot>
                  <i id='FPumN'><tr id='FPumN'><dt id='FPumN'><q id='FPumN'><span id='FPumN'><b id='FPumN'><form id='FPumN'><ins id='FPumN'></ins><ul id='FPumN'></ul><sub id='FPumN'></sub></form><legend id='FPumN'></legend><bdo id='FPumN'><pre id='FPumN'><center id='FPumN'></center></pre></bdo></b><th id='FPumN'></th></span></q></dt></tr></i><div id='FPumN'><tfoot id='FPumN'></tfoot><dl id='FPumN'><fieldset id='FPumN'></fieldset></dl></div>

                    <tbody id='FPumN'></tbody>
                  本文介绍了selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的代码脚本:

                  从 selenium 导入 webdriver选项 = webdriver.ChromeOptions()options.add_argument("user-data-dir=C:\Users\hadi\AppData\Local\Google\Chrome\User Data") #您的 chrome 配置文件的路径w = webdriver.Chrome(executable_path="E:Pythonchromedriver.exe", chrome_options=options)w.get("https://www.facebook.com")

                  在运行此脚本时出现此错误:

                  Traceback(最近一次调用最后一次):<module> 中的文件E:/Python/MoosaBhai/TestoTes.py",第 6 行w = webdriver.Chrome(executable_path="E:\Python\chromedriver.exe", chrome_options=options)__init__ 中的文件C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriverchromewebdriver.py",第 75 行期望的能力=期望的能力)文件C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py",第 154 行,在 __init__self.start_session(desired_capabilities, browser_profile)文件C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py",第 243 行,在 start_session响应 = self.execute(Command.NEW_SESSION,参数)文件C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py",第 312 行,在执行中self.error_handler.check_response(响应)文件C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emoteerrorhandler.py",第 242 行,在 check_response引发异常类(消息、屏幕、堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:崩溃(驱动程序信息:chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),平台=Windows NT 10.0.17134 x86_64)

                  我已经编辑了 chromedriver 的可执行路径,但是当我运行脚本时,我的 chrome 驱动程序会打开,但之后会卡住 2-3 分钟,然后因上述以下错误而崩溃.

                  解决方案

                  拇指规则

                  <块引用>

                  Chrome 在启动过程中崩溃的一个常见原因是作为 root 用户(administrator 运行 Chrome>) 在 Linux 上.虽然可以通过在创建 WebDriver 会话时传递 --no-sandbox 标志来解决此问题,但这种配置不受支持且不鼓励使用.您需要将环境配置为以普通用户身份运行 Chrome.


                  根据您的代码试验,您似乎正在尝试访问 Chrome 配置文件,因此您可以使用以下解决方案:

                  • 代码块:

                    从 selenium 导入 webdriver从 selenium.webdriver.chrome.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	ochromedriver.exe', chrome_options=options)driver.get("https://www.google.co.in")

                  • 您可以在此处找到详细讨论 如何通过 Python 打开 Chrome 配置文件

                  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:Pythonchromedriver.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:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriverchromewebdriver.py", line 75, in __init__
                      desired_capabilities=desired_capabilities)
                    File "C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 154, in __init__
                      self.start_session(desired_capabilities, browser_profile)
                    File "C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 243, in start_session
                      response = self.execute(Command.NEW_SESSION, parameters)
                    File "C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 312, in execute
                      self.error_handler.check_response(response)
                    File "C:UsershadiAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
                  emoteerrorhandler.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.

                  解决方案

                  Thumb rule

                  A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. 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. You need to configure your environment to run Chrome as a regular user instead.


                  As per your code trials seems you are trying to access a Chrome Profile so you can use the following solution:

                  • 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	ochromedriver.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

                  这篇关于selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Selenium 不打开指定的 URL 并显示数据:, 下一篇:SessionNotCreatedException:消息:无法创建新服务:通过

                  相关文章

                  最新文章

                  • <bdo id='I5lPb'></bdo><ul id='I5lPb'></ul>

                  <tfoot id='I5lPb'></tfoot>

                  <small id='I5lPb'></small><noframes id='I5lPb'>

                    <i id='I5lPb'><tr id='I5lPb'><dt id='I5lPb'><q id='I5lPb'><span id='I5lPb'><b id='I5lPb'><form id='I5lPb'><ins id='I5lPb'></ins><ul id='I5lPb'></ul><sub id='I5lPb'></sub></form><legend id='I5lPb'></legend><bdo id='I5lPb'><pre id='I5lPb'><center id='I5lPb'></center></pre></bdo></b><th id='I5lPb'></th></span></q></dt></tr></i><div id='I5lPb'><tfoot id='I5lPb'></tfoot><dl id='I5lPb'><fieldset id='I5lPb'></fieldset></dl></div>

                    1. <legend id='I5lPb'><style id='I5lPb'><dir id='I5lPb'><q id='I5lPb'></q></dir></style></legend>