How to set default download directory in selenium Chrome Capabilities?

前端 未结 6 1870
独厮守ぢ
独厮守ぢ 2020-12-01 14:17

Please find the below code with the chrome capabilities. In fact the browser is not downloading the file to the specified path.

private static DesiredCapabi         


        
6条回答
  •  既然无缘
    2020-12-01 14:54

    The ans which help me to resolve this issue on windows (https://bugs.chromium.org/p/chromedriver/issues/detail?id=783).

    Map prefs = new HashMap();
    prefs.put("download.default_directory",  System.getProperty("user.dir")+ File.separator + "externalFiles" + File.separator + "downloadFiles");
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", prefs);
    ChromeDriver driver = new ChromeDriver(options);
    

提交回复
热议问题