• <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 功能)已弃用

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

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

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)
                    <tbody id='LCgeg'></tbody>

                  <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>