Search code examples
seleniumselenium-webdrivermicrosoft-edgegeb

Is there any egde webdriver documentation about preferences?


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.


Solution

  • 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.