2021年5月5日星期三

Selenium Firefox Preference for opening downloaded files

I've been looking for a way to download and run a JNLP file when using Selenium and Firefox. In the Firefox browser, I have the setting as shown in the screenshot below, so that the JNLP file downloads and runs without any popups.

enter image description here

Is it possible to replicate this is with FireFox Profile? I have the following set up, but it only downloads the file, it isn't automatically opening the file:

void setFireFoxDriverProperty(){         System.setProperty("webdriver.gecko.driver","C:\\TestAutomation\\selenium_drivers\\geckodriver.exe")        FirefoxProfile profile = new FirefoxProfile()      profile.setPreference("browser.download.folderList", 2)      profile.setPreference("browser.download.manager.showWhenStarting", false)      profile.setPreference("browser.download.dir", "c:\\temp")      profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-java-jnlp-file")      profile.setPreference("browser.helperApps.neverAsk.openFile", "application/x-java-jnlp-file")        FirefoxOptions options = new FirefoxOptions()      options.setProfile(profile)      driver = new FirefoxDriver(options)  }  
https://stackoverflow.com/questions/67411689/selenium-firefox-preference-for-opening-downloaded-files May 06, 2021 at 12:04PM

没有评论:

发表评论