3
votes

I have been playing around with Selenium Java WebDriver using chrome browser and have a fair amount of success so far. I have been able to start chrome window and send and receive data just fine. I now need to figure out the chrome equivalent of the following profile settings for Firefox browser.

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "image/jpg");
profile.setPreference("browser.download.dir", "path/to/downloads/pics/folder");

Planning on doing something like this (ref: https://sites.google.com/a/chromium.org/chromedriver/capabilities) but need set the other properties as above.

ChromeOptions chromeOptions = new ChromeOptions();
//set the rest of the preferences for chrome as shown above for Firefox
  • Selenium: 2.47.1
  • Mac: OsX Yosemite
  • ChromeDriver: 2.18
  • JDK: 1.8x

Thanks.

1

1 Answers

4
votes

Try this:

    ChromeOptions options = new ChromeOptions();  
    options.addArguments("--browser.download.folderList=2");
    options.addArguments("--browser.helperApps.neverAsk.saveToDisk=image/jpg");
    options.addArguments("--browser.download.dir=path/to/downloads/pics/folder");
    driver = new ChromeDriver(options);