how to change file download location in Webdriver while using chrome driver/firefox driver

后端 未结 7 717
太阳男子
太阳男子 2020-11-30 07:42

I am trying to save an image by using save as option inside a specific folder. I found a way by which I am able to right click on the image which I want to save using save a

7条回答
  •  情话喂你
    2020-11-30 08:10

    For Chrome, it will works

    String downloadFilepath = "/path/to/download";
    HashMap chromePrefs = new HashMap();
    chromePrefs.put("profile.default_content_settings.popups", 0);
    chromePrefs.put("download.default_directory", downloadFilepath);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", chromePrefs);
    WebDriver driver = new ChromeDriver(options);
    

提交回复
热议问题