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

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

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

      1. InvalidArgumentException:消息:无效参数:用户数据目录

        时间:2023-10-08

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

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

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

                • 本文介绍了InvalidArgumentException:消息:无效参数:用户数据目录已在使用错误使用 --user-data-dir 使用 Selenium 启动 Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我尝试使用 --user-data-dir 让当前用户使用 Selenium 启动 Chrome 时,我收到以下错误:

                  When I am trying to use --user-data-dir for the current user to start Chrome using Selenium I am getting an error as:

                    File "C:Program Files (x86)Pythonlibsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 321, in execute
                      self.error_handler.check_response(response)
                    File "C:Program Files (x86)Pythonlibsite-packagesseleniumwebdriver
                  emoteerrorhandler.py", line 242, in check_response
                      raise exception_class(message, screen, stacktrace)
                  selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
                  

                  我该如何解决这个错误?

                  How can I fix this error?

                  推荐答案

                  这个错误信息...

                  selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
                  

                  ...暗示 ChromeDriver 无法使用指定的 用户数据目录 启动新的 Chrome 浏览器 会话,因为它已经正在使用中.

                  ...implies that the ChromeDriver was unable to initiate the new Chrome Browser session using the specified user data directory as it was already in use.

                  这个错误可以重现如下:

                  This error can be reproduced as follows:

                  • 代码块:

                  • Code Block:

                  from selenium import webdriver
                  import getpass
                  
                  options = webdriver.ChromeOptions() 
                  options.add_argument("start-maximized")
                  options.add_argument(r"--user-data-dir=C:Users{}AppDataLocalGoogleChromeUser Data".format(getpass.getuser()))
                  driver = webdriver.Chrome(options=options, executable_path=r'C:WebDriverschromedriver.exe')
                  driver.get("https://www.google.com/")
                  

                • 完成相关回溯:

                • Complete relevant traceback:

                  [12148:21412:0204/035557.731:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
                  [12148:21412:0204/035557.731:ERROR:cache_util.cc(141)] Unable to move cache folder C:UsersSoma BhattacharjeeAppDataLocalGoogleChromeUser DataShaderCacheGPUCache to C:UsersSoma BhattacharjeeAppDataLocalGoogleChromeUser DataShaderCacheold_GPUCache_000
                  [12148:21412:0204/035557.731:ERROR:disk_cache.cc(178)] Unable to create cache
                  [12148:21412:0204/035557.731:ERROR:shader_disk_cache.cc(605)] Shader Cache Creation failed: -2
                  Opening in existing browser session.
                  Traceback (most recent call last):
                    File "C:UsersSoma BhattacharjeeDesktopDebanjanPyProgramsyandex_ru.py", line 18, in <module>
                      driver = webdriver.Chrome(options=options, executable_path=r'C:WebDriverschromedriver.exe')
                    File "C:Pythonlibsite-packagesseleniumwebdriverchromewebdriver.py", line 81, in __init__
                      desired_capabilities=desired_capabilities)
                    File "C:Pythonlibsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 157, in __init__
                      self.start_session(capabilities, browser_profile)
                    File "C:Pythonlibsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 252, in start_session
                      response = self.execute(Command.NEW_SESSION, parameters)
                    File "C:Pythonlibsite-packagesseleniumwebdriver
                  emotewebdriver.py", line 321, in execute
                      self.error_handler.check_response(response)
                    File "C:Pythonlibsite-packagesseleniumwebdriver
                  emoteerrorhandler.py", line 242, in check_response
                      raise exception_class(message, screen, stacktrace)
                  selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
                  

                • 错误堆栈跟踪清楚地抱怨 访问被拒绝,因为程序无法将缓存文件夹 ..ShaderCacheGPUCache 移动到 ..ShaderCacheold_GPUCache_000.因此 cache 创建失败,随后 Shader Cache Creation 创建失败.虽然这些问题会引发 InvalidArgumentException,但可以在现有 Chrome 浏览器会话中强制打开一个新窗口.

                  The error stack trace clearly complains of Access is denied as the program was unable to move the cache folder ..ShaderCacheGPUCache to ..ShaderCacheold_GPUCache_000. hence the creation of cache failed and subsequently creation of Shader Cache Creation failed. Though these issues raises the InvalidArgumentException but forcefully able to open a new window within the existing Chrome Browser Session.

                  虽然抛出了错误,但新的 Chrome 窗口仍会启动,但仍与已打开的 Chrome 会话连接,但新窗口无法由 WebDriver 实例.因此,您会在 url 栏中看到 data:,.

                  Though the error is thrown, still the new Chrome window gets initiated but remains attached with the already opened Chrome session but the new window can't be controlled by the WebDriver instance. Hence you see data:, in the url bar.

                  你需要注意几件事:

                  • 如果您使用 默认 Chrome 配置文件在同一台测试机上访问其他工作的网页,则不应设置 user-data-dir 作为用户数据,因为它仍然被您手动启动的其他 Chrome 进程锁定.
                    • 在上述场景中,您需要创建和使用另一个 Chrome 配置文件,您可以在 如何通过 Python 打开 Chrome 配置文件
                    • If you are using the Default Chrome Profile to access webpages for your other work on the same Test Machine, you shouldn't set user-data-dir as the User Data as it remains locked by the other Chrome process you have initiated manually.
                      • In the above scenario you need to create and use another Chrome Profile and you can find a detailed discussion in How to open a Chrome Profile through Python
                      • 在上述场景中,您需要创建和使用另一个 Chrome 配置文件,您可以在 如何在 Selenium Webdriver Python 3 中使用 Chrome 配置文件
                      • In the above scenario you need to create and use another Chrome Profile and you can find a detailed discussion in How to use Chrome Profile in Selenium Webdriver Python 3
                      • 您可以在 如何通过 Selenium 的 --user-data-dir 参数打开 Chrome 配置文件

                      这篇关于InvalidArgumentException:消息:无效参数:用户数据目录已在使用错误使用 --user-data-dir 使用 Selenium 启动 Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:WebDriverException:消息:服务 chromedriver 意外退出.状态 下一篇:通过 Selenium - Python 在新选项卡中打开网址的最快

                  相关文章

                  最新文章

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

                    1. <small id='hLgpj'></small><noframes id='hLgpj'>