# How to setup Firefox to download files without prompt during Katalon test execution?

**URL:** <https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 22, 2020, 9:29am UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936 "2020-01-22T09:29:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![michal.jeruzal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/michal.jeruzal/32/16104_2.png) [@michal.jeruzal](https://forum.katalon.com/u/michal.jeruzal)\
**Post date:** [January 22, 2020, 9:29am UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/1 "2020-01-22T09:29:59Z")

</div>

Hi!

I am trying to create a very simple Katalon test case that opens Firefox, goes to given URL and clicks a button to download a file. I have set up Desired Capabilities according to the Katalon documentation ([https://github.com/katalon-studio/docs/blob/master/pages/katalon-studio/docs/introduction-to-desired-capabilities.md](https://github.com/katalon-studio/docs/blob/master/pages/katalon-studio/docs/introduction-to-desired-capabilities.md)) but with no luck. When I try to download a file prompt shows up and file is not downloaded. How can I disable the prompt and download the file immediately instead?

Software versions, source code and screenshots below.

Windows 10, Katalon Studio 7.2.1, Mozilla Firefox 72.0.2, Selenium 3.141.59

```
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser('https://file-examples.com/index.php/text-files-and-archives-download/')

WebUI.click(findTestObject('downloadCsvFileButton'))

```

![](https://i.stack.imgur.com/Nse5h.png)  
 ![](https://i.stack.imgur.com/imuuP.png)

---

<div class="post-metadata">

**Author:** ![Timo\_Kuisma1](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/timo_kuisma1/32/16103_2.png) [@Timo\_Kuisma1](https://forum.katalon.com/u/Timo_Kuisma1)\
**Post date:** [January 22, 2020, 3:40pm UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/2 "2020-01-22T15:40:28Z")

</div>

hello,

do it using Selenium Webdriver class

```
//parameter File where your downloadpath is and return Webdriver object
public WebDriver setChromeOptions(File folder){
	
	ChromeOptions options = new ChromeOptions();
	String downloadPath = folder.getAbsolutePath()
	//String downloadsPath = System.getProperty("user.home") + "/Downloads";
	println ("downloadpath "+downloadPath)
	
	Map<String, Object> chromePrefs = new HashMap<String, Object>()
	chromePrefs.put("profile.default_content_settings.popups", 0);
	chromePrefs.put("download.default_directory", downloadPath)
	chromePrefs.put("download.prompt_for_download", false)
	chromePrefs.put("plugins.plugins_disabled", "Chrome PDF Viewer");
	options.addArguments("--window-size=1920,1080")
	options.addArguments("--test-type")
	options.addArguments("--disable-gpu")
	options.addArguments("--no-sandbox")
	options.addArguments("--disable-dev-shm-usage")
	options.addArguments("--disable-software-rasterizer")
	options.addArguments("--disable-popup-blocking")
	options.addArguments("--disable-extensions")
	options.setExperimentalOption("prefs", chromePrefs)
	DesiredCapabilities cap = DesiredCapabilities.chrome()
	cap.setCapability(ChromeOptions.CAPABILITY, options)
	cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
	
	System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
	WebDriver driver = new ChromeDriver(cap);
	return driver
}
```

---

<div class="post-metadata">

**Author:** ![michal.jeruzal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/michal.jeruzal/32/16104_2.png) [@michal.jeruzal](https://forum.katalon.com/u/michal.jeruzal)\
**Post date:** [January 23, 2020, 9:09am UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/3 "2020-01-23T09:09:46Z")

</div>

Hi @Timo_Kuisma1,  
For Chrome I can setup Desired Capabilities in Project Settings and it works fine, what I was struggling with was Firefox.

Anyway, I found this topic [Opening Firefox with a Specific, non anonymous profile](http://forum.katalon.com/t/opening-firefox-with-a-specific-non-anonymous-profile/12012/15) and @kazurayam’s reply helped me to create a script that initializes webdriver and I call it before each TestCase:

```
import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.firefox.ProfilesIni
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.driver.WebUIDriverType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

WebUIDriverType executedBrowser = DriverFactory.getExecutedBrowser()
switch(executedBrowser) {
	case WebUIDriverType.FIREFOX_DRIVER: // "Firefox"
		System.setProperty('webdriver.gecko.driver', DriverFactory.getGeckoDriverPath())
		FirefoxOptions options = new FirefoxOptions()
				
		options.addPreference('marionette', true)
		options.addPreference('browser.download.folderList', 2)
		options.addPreference('browser.helperApps.alwaysAsk.force', false)
		options.addPreference('browser.download.manager.showWhenStarting', false)
		options.addPreference('browser.download.dir', GlobalVariable.downloadPath)
		options.addPreference('browser.download.downloadDir', GlobalVariable.downloadPath)
		options.addPreference('browser.download.defaultFolder', GlobalVariable.downloadPath)
		options.addPreference('browser.helperApps.neverAsk.saveToDisk', 'application/download, application/octet-stream, text/csv')
		
		WebDriver driver = new FirefoxDriver(options);
		// let Katalon Studio to use the WebDriver created here
		DriverFactory.changeWebDriver(driver)
		break
	default:
		WebUI.openBrowser('')
}

```

If someone wants to download different file types they have to specify the MIME types in ‘browser.helperApps.neverAsk.saveToDisk’ preference:  
[https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics\_of\_HTTP/MIME\_types/Complete\_list\_of\_MIME\_types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types)  
Additionally, if the file is PDF you have to add one more preference:  
`options.addPreference('pdfjs.disabled', true)`

---

<div class="post-metadata">

**Author:** ![jpotrawski](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jpotrawski/32/23870_2.png) [@jpotrawski](https://forum.katalon.com/u/jpotrawski)\
**Post date:** [February 5, 2020, 8:30pm UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/4 "2020-02-05T20:30:21Z")

</div>

Could I see the Desired Capabilities you set in Project Settings for Chrome? I was having issues with a download prompt appearing on PDF and Excel files.

---

<div class="post-metadata">

**Author:** ![michal.jeruzal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/michal.jeruzal/32/16104_2.png) [@michal.jeruzal](https://forum.katalon.com/u/michal.jeruzal)\
**Post date:** [February 5, 2020, 9:02pm UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/5 "2020-02-05T21:02:13Z")

</div>

Sure, I will post my configuration tomorrow morning (I am in CET time zone).

---

<div class="post-metadata">

**Author:** ![michal.jeruzal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/michal.jeruzal/32/16104_2.png) [@michal.jeruzal](https://forum.katalon.com/u/michal.jeruzal)\
**Post date:** [February 6, 2020, 8:33am UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/6 "2020-02-06T08:33:41Z")

</div>

I have checked my settings for Chrome. It is nothing fancy, but it works for me with PDFs. The page I am testing has a valid SSL certificate and I am downloading PDF which is generated dynamically, I have checked the MIME type of the file and it appears as ‘application/octet-stream’.

So, I have defined a Desired Capability:

- name: prefs; type: Dictionary;  
And in dictionary value I have a property:
- name: download.default\_directory; type: String; value: C:\Downloads

That is all.

---

<div class="post-metadata">

**Author:** ![jpotrawski](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jpotrawski/32/23870_2.png) [@jpotrawski](https://forum.katalon.com/u/jpotrawski)\
**Post date:** [February 6, 2020, 2:22pm UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/7 "2020-02-06T14:22:32Z")

</div>

Why did you find this solution to work as opposed to using Project Settings / Desired Capabilities for Firefox? (referring to the script)

I had similar settings for Firefox in Katalon but it just doesn’t want to work, and it’s incredibly frustrating.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 6, 2020, 4:44pm UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/8 "2020-02-06T16:44:38Z")

</div>

Split this topic on February 6, 2020, 4:44pm UTC

3 posts were split to a new topic: [Use new FirefoxOptions() instead of Desired Capabilities](https://forum.katalon.com/t/use-new-firefoxoptions-instead-of-desired-capabilities/39571)

---

<div class="post-metadata">

**Author:** ![AndyG72](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andyg72/32/16103_2.png) [@AndyG72](https://forum.katalon.com/u/AndyG72)\
**Post date:** [May 27, 2021, 6:58am UTC](https://forum.katalon.com/t/how-to-setup-firefox-to-download-files-without-prompt-during-katalon-test-execution/38936/9 "2021-05-27T06:58:52Z")

</div>

Same here. Extremely frustrating that the same settings do not work in project settings for firefox. Got to love ‘codeless’ tools, right? 😉

@jpotrawski Did you ever get this working through project settings?
