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

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

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

      2. <tfoot id='B4MPv'></tfoot><legend id='B4MPv'><style id='B4MPv'><dir id='B4MPv'><q id='B4MPv'></q></dir></style></legend>

        InvalidArgumentException:消息:无效参数:用户数据目录已在使用错误使用 --user-data-

        InvalidArgumentException: Message: invalid argument: user data directory is already in use error using --user-data-dir to start Chrome using Selenium(InvalidArgumentException:消息:无效参数:用户数据目录已在使用错误使用 --user-data-dir 使用 S
        • <bdo id='CqMUu'></bdo><ul id='CqMUu'></ul>

          1. <tfoot id='CqMUu'></tfoot>

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

                • <legend id='CqMUu'><style id='CqMUu'><dir id='CqMUu'><q id='CqMUu'></q></dir></style></legend>
                    <tbody id='CqMUu'></tbody>
                  <i id='CqMUu'><tr id='CqMUu'><dt id='CqMUu'><q id='CqMUu'><span id='CqMUu'><b id='CqMUu'><form id='CqMUu'><ins id='CqMUu'></ins><ul id='CqMUu'></ul><sub id='CqMUu'></sub></form><legend id='CqMUu'></legend><bdo id='CqMUu'><pre id='CqMUu'><center id='CqMUu'></center></pre></bdo></b><th id='CqMUu'></th></span></q></dt></tr></i><div id='CqMUu'><tfoot id='CqMUu'></tfoot><dl id='CqMUu'><fieldset id='CqMUu'></fieldset></dl></div>
                  本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                    <i id='lB8cJ'><tr id='lB8cJ'><dt id='lB8cJ'><q id='lB8cJ'><span id='lB8cJ'><b id='lB8cJ'><form id='lB8cJ'><ins id='lB8cJ'></ins><ul id='lB8cJ'></ul><sub id='lB8cJ'></sub></form><legend id='lB8cJ'></legend><bdo id='lB8cJ'><pre id='lB8cJ'><center id='lB8cJ'></center></pre></bdo></b><th id='lB8cJ'></th></span></q></dt></tr></i><div id='lB8cJ'><tfoot id='lB8cJ'></tfoot><dl id='lB8cJ'><fieldset id='lB8cJ'></fieldset></dl></div>

                        • <legend id='lB8cJ'><style id='lB8cJ'><dir id='lB8cJ'><q id='lB8cJ'></q></dir></style></legend>

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

                            <tbody id='lB8cJ'></tbody>
                          <tfoot id='lB8cJ'></tfoot>
                            <bdo id='lB8cJ'></bdo><ul id='lB8cJ'></ul>