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

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

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

      3. ChromeDriver(Capabilities 功能)已弃用

        时间:2023-09-28

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

            • <bdo id='Aptru'></bdo><ul id='Aptru'></ul>
              <tfoot id='Aptru'></tfoot>

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

                  <tbody id='Aptru'></tbody>

                1. 本文介绍了ChromeDriver(Capabilities 功能)已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我使用 ChromeDriver 2.33WebDriver 3.6.0 并尝试设置文件下载的默认目录.

                  I use ChromeDriver 2.33 with WebDriver 3.6.0 and try to set default directory for file download.

                  Map<String, Object> prefs = new HashMap<String, Object>();
                  prefs.put("download.default_directory", Vars.DOWNLOAD_FOLDER_ROOT);
                  DesiredCapabilities caps = DesiredCapabilities.chrome();
                  
                  ChromeOptions options = new ChromeOptions();
                  options.addArguments("--start-maximized");
                  options.setExperimentalOption("prefs", prefs);
                  caps.setCapability(ChromeOptions.CAPABILITY, options);
                  driver = new ChromeDriver(caps);
                  

                  我在文档中找到了这个:

                  I found this in docs:

                  改用 ChromeDriver(ChromeOptions).创建一个新的 ChromeDriver实例.这些功能将传递给 chromedriver 服务.

                  Use ChromeDriver(ChromeOptions) instead. Creates a new ChromeDriver instance. The capabilities will be passed to the chromedriver service.

                  推荐答案

                  我希望您想询问解决方法以避免弃用.

                  I hope you wanted to ask about the workaround to avoid the deprecation.

                  仅使用 Capabilities 构建的旧方法已被弃用.现在,它需要一个 ChromeDriverService &Capabilities 作为参数.因此,只需构建一个 ChromeDriverService 并将其与您的 Capabilities 一起传递即可删除弃用警告.

                  The old method of just building with Capabilities is deprecated. Now, it takes a ChromeDriverService & Capabilities as parameters. So, just a build a ChromeDriverService and pass the same along with your Capabilities to remove the deprecation warning.

                  DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                  
                  ChromeDriverService service = new ChromeDriverService.Builder()
                                      .usingDriverExecutable(new File("/usr/local/chromedriver"))
                                      .usingAnyFreePort()
                                      .build();
                  ChromeDriver driver = new ChromeDriver(service, capabilities);
                  

                  由于 ChromeDriver(service, capabilities) 现在也已弃用,您可以使用,

                  Since ChromeDriver(service, capabilities) is deprecated now as well, you can use,

                  DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                  
                  ChromeDriverService service = new ChromeDriverService.Builder()
                                              .usingDriverExecutable(new File("/usr/local/chromedriver"))
                                              .usingAnyFreePort()
                                              .build();
                  ChromeOptions options = new ChromeOptions();
                  options.merge(capabilities);    
                  ChromeDriver driver = new ChromeDriver(service, options);
                  

                  但是,您可以完全跳过 DesiredCapabilities 并仅将 ChromeOptionssetCapability 方法一起使用,

                  However, You can completely skip DesiredCapabilities and use only ChromeOptions with setCapability method like,

                  ChromeOptions options = new ChromeOptions();
                  options.setCapability("capability_name", "capability_value");
                  driver = new ChromeDriver(options);
                  

                  这篇关于ChromeDriver(Capabilities 功能)已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过 Selenium WebDriver 从下拉列表中选择一个选 下一篇:如何使用 chrome 驱动程序使用 Java 覆盖 selenium2 中

                  相关文章

                  最新文章

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

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

                    2. <tfoot id='QjnH3'></tfoot>