Access to file download dialog in Firefox

前端 未结 11 2616
一个人的身影
一个人的身影 2020-11-22 07:02

Is there any kind of API that can allow me to manipulate a file download dialog in Firefox? (I want to access the one that appears when user does something, not initiate one

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 07:52

    In addition you can add

          profile.setPreference("browser.download.panel.shown",false);
    

    To remove the downloaded file list that gets shown by default and covers up part of the web page.

    My total settings are:

            DesiredCapabilities dc = DesiredCapabilities.firefox();
            dc.merge(capabillities);
            FirefoxProfile profile = new FirefoxProfile();
            profile.setAcceptUntrustedCertificates(true);
            profile.setPreference("browser.download.folderList", 4);
            profile.setPreference("browser.download.dir", TestConstants.downloadDir.getAbsolutePath());
            profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword, application/csv, application/ris, text/csv, data:image/png, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.manager.focusWhenStarting", false);
            profile.setPreference("browser.download.useDownloadDir", true);
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
            profile.setPreference("browser.download.manager.closeWhenDone", true);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.useWindow", false);
            profile.setPreference("browser.download.panel.shown",false);
            dc.setCapability(FirefoxDriver.PROFILE, profile);
            this.driver = new FirefoxDriver(dc);
    

提交回复
热议问题