3

I am currently trying to create cross-browser automated tests with Geb but I cannot find any documentation about preferences with Edge. What I am trying to do is to set up my Edge environment to automatically download documents and save them in downloads/edge. I have done this way for chrome and firefox:

customChrome {
    driver = {
        System.setProperty("webdriver.chrome.driver", new File ("Drivers/chromedriver_win32/chromedriver.exe").getAbsolutePath())
        Map<String, Object> chromePrefs = new HashMap<String, Object>()
        chromePrefs.put("download.default_directory", new File("downloads/chrome").getAbsolutePath())
        chromePrefs.put("download.prompt_for_download", false)
        chromePrefs.put("plugins.always_open_pdf_externally", true)
        ChromeOptions opt = new ChromeOptions()
        opt.setExperimentalOption("prefs", chromePrefs)
        new ChromeDriver(opt)
    }
}

customFF {
    driver = {

        FirefoxProfile myProfile = new FirefoxProfile()

        myProfile.setPreference("browser.helperApps.alwaysAsk.force", false)
        myProfile.setPreference("browser.download.manager.showWhenStarting", false)
        myProfile.setPreference("browser.download.folderList", 2)
        myProfile.setPreference("browser.download.dir", new File("downloads/firefox").getAbsolutePath()) // my downloading dir
        myProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false)
        myProfile.setPreference("browser.download.useDownloadDir", true)
        myProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf, image/jpeg")

        myProfile.setPreference("pdfjs.disabled", true)

        System.setProperty("webdriver.gecko.driver", new File("Drivers/GeckoDriver/geckodriver.exe").getAbsolutePath())
        new FirefoxDriver(myProfile)
    }
}

I used this source file to get chrome's prefs and this webpage for getting those of firefox but I cannot find anything similar for Edge. Does Microsoft provides any info about this ? Please share any info you may have.

Saub
  • 47
  • 6

1 Answers1

0

I'm not sure if things have changed since, but according to this answer IE doesn't use profiles and is therefore unable to download files to a specific location.

Rushby
  • 869
  • 9
  • 18
  • 1
    Thank you for your help, that confirms what I was afraid of. However I managed to find a way to set up IE and Edge by modifying registry values through a .reg file called by a batch script. It is not very elegant but it does the job. Found help [here](https://www.tenforums.com/tutorials/46038-turn-off-download-save-prompt-microsoft-edge.html) and [here](http://www.mentorlog.com/2010/computer/how-to-disable-or-enable-downloads-in-internet-explorer-using-registry.html) – Saub Jun 28 '17 at 14:52