【问题标题】:How to spcify the download location for IE11 and edge browsers using Selenium bindings如何使用 Selenium 绑定指定 IE11 和边缘浏览器的下载位置
【发布时间】:2018-04-24 16:47:03
【问题描述】:

Selenium C# 绑定能够指定 chrome 下载位置:

var options = new ChromeOptions().AddUserProfilePreference("download.default_directory", "D:\Downloads");

Edge 和 IE11 是否存在任何适当的实现?

【问题讨论】:

    标签: selenium internet-explorer microsoft-edge microsoft-webdriver


    【解决方案1】:

    IE 不使用配置文件。因此,无法使用 Internet Explorer 自动将文件下载到指定位置。

    【讨论】:

      【解决方案2】:

      对于 Edge,请尝试以下更改默认下载位置:

      EdgeOptions options = new EdgeOptions();
      Map<String, Object> prefs = new HashMap<String, Object>();
      prefs.put("profile.default_content_settings.popups", 0);
      prefs.put("download.default_directory",
      System.getProperty("user.dir")+"\\downloads");
      prefs.put("download.prompt_for_download", false);
      Map<String, Object> edgeOptions = new HashMap<String, Object>();
      edgeOptions.put("prefs", prefs);
      edgeOptions.put("useAutomationExtension", false);
      options.setCapability("ms:edgeChrominum", true);
      options.setCapability("ms:edgeOptions", edgeOptions);
      WebDriver driver = new EdgeDriver(options);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-10-04
        • 1970-01-01
        • 1970-01-01
        • 2015-03-12
        • 2016-03-22
        • 2019-09-29
        相关资源
        最近更新 更多