12

Here's how you create a Firefox profile:

fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.dir", download_dir)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv")

How do you do it with PhantomJS (GhostDriver)?

luksch
  • 11,497
  • 6
  • 38
  • 53
User
  • 23,729
  • 38
  • 124
  • 207
  • 3
    PhantomJS doesn't support automatic downloading, so there is no such "profile" that would make sense. – Artjom B. Dec 12 '15 at 11:35

1 Answers1

4

The closest you can get with phantomjs is to use the driver capabilities:

DesiredCapabilities caps = DesiredCapabilities.phantomjs();
caps.setCapability( "phantomjs.page.settings.userAgent", "Mozilla");
Set<String> cliArgs = new HashSet<>();
cliArgs.add("--ignore-ssl-errors=true");
cliArgs.add("--ssl-protocol=any");
cliArgs.add("--web-security=false");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);
driver = new PhantomJSDriver(caps);

However, you notice that there are no configuration options for automatic downloading, since phantomjs does not support this. It is anyway not a very good idea to use selenium for testing of downloads. I did answer another related question earlier in which I point to an article about this and why you should not do it.

Community
  • 1
  • 1
luksch
  • 11,497
  • 6
  • 38
  • 53