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


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 ( 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 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 as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys



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.setExperimentalOption("prefs", chromePrefs)
	DesiredCapabilities cap =
	cap.setCapability(ChromeOptions.CAPABILITY, options)
	cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
	System.setProperty("", DriverFactory.getChromeDriverPath())
	WebDriver driver = new ChromeDriver(cap);
	return driver

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 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('', 2)
		options.addPreference('browser.helperApps.alwaysAsk.force', false)
		options.addPreference('', false)
		options.addPreference('', GlobalVariable.downloadPath)
		options.addPreference('', GlobalVariable.downloadPath)
		options.addPreference('', 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

If someone wants to download different file types they have to specify the MIME types in ‘browser.helperApps.neverAsk.saveToDisk’ preference:
Additionally, if the file is PDF you have to add one more preference:
options.addPreference('pdfjs.disabled', true)

1 Like

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.

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

1 Like

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.

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.

3 posts were split to a new topic: Use new FirefoxOptions() instead of Desired Capabilities

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

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