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

      <legend id='qqyaE'><style id='qqyaE'><dir id='qqyaE'><q id='qqyaE'></q></dir></style></legend>
      1. <small id='qqyaE'></small><noframes id='qqyaE'>

          <bdo id='qqyaE'></bdo><ul id='qqyaE'></ul>
        <tfoot id='qqyaE'></tfoot>
      2. ChromeDriver(Capabilities 功能)已弃用

        时间:2023-06-27
          • <bdo id='F4WFp'></bdo><ul id='F4WFp'></ul>
            <tfoot id='F4WFp'></tfoot>

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

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

                  本文介绍了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 功能)已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何通过 Selenium WebDriver 从下拉列表中选择一个选项 下一篇:更新到 ChromeDriver 2.46 后 Chrome 版本必须介于 71 和 75 之间的错误

                  相关文章

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

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

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