Download files from web ui not working

Hi all,

The above solution worked for me. But can anyone tell me how can i enable download popup in chrome browser.

i have done -
download.prompt_for_download as true

still i didn’t get popup.

Thanks in advanced!!

Hi all,

I can’t solve my download problem.
I am using Katalon studio version 5.6.3 and
Chrome Version 68.0.3440.106 (Official Build) (64-bit).
I have same problem like @Girish Mohite
When i click on download button new window is opened.
I cant record anything with SPY WEB on that new window. That means i cant click on download button. That is why i tried to simulate CTRL + S, but since i cant record anything on that new windows i cant sendKeys to object.
So i used robot class.
When i simulate CTRL+S with robot class SAVE AS windows appears.
Is there anything i can do to to avoid SAVE AS dialog?

My Chrome settings:

Chrome_settings.PNG

Thank you so much. This worked for me :slight_smile:

Hi,

This one is as well my problem before. And it took me weeks to solve. Got them solved (with God’s help). See below Desired Capabilities applied in Chrome execution settings:


prefs contains:
profile.default_content_settings.popups | Number | 0
download.default_directory | String | C:\Shared - you can change the path to your desired location

args contains:
String | --test-type
String | --disable-extensions

Hope this helps.

My problem now is how to set the filename accdg to my preference. That, i am still working on.

1 Like

Hi, @Zarashima

I had followed the step, to put the dictionary in firefox_profile. However, I still get the pop up. Is there any mistake I made?.

Thanks in advance. :slight_smile:

Hello all,

it still not working with me too
i am using: Firefox 64.0.2 (64-bit), Katalon Studio Version: 5.10.1 Build: 1, Win 7/64

thanks for your kind of help.
roy

Hi @roy_heuward

I figured out aldy.

Please refer to this post. Hope it helps you~
https://stackoverflow.com/questions/36309314/set-firefox-profile-to-download-files-automatically-using-selenium-and-java#=

Have a nice day~

Hi @Chua_Au_Mei,

many thanks for your kind help that worked for me.

have a great day :slight_smile:

Hi guys,

Thanks for the help.
Both Chrome and Firefox is working like a charm.

However, I was wondering if it is possible to make download path dynamic for both Firefox and Chrome as it is required to pass the absolute path which varies based on the OS.

Have a great day.

the only error is browser spelling

I am unable to download file using Chrome browser, download window getting closed with out downloading the required file, could you please send me the code and the required setting for Chrome using Katalon studio.

Thanks in Advance.

try this

import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import com.kms.katalon.core.webui.driver.DriverFactory
 
String downloadPath = "C:\\customDownloadFolder\\"
 
Map<String, Object> chromePrefs = new HashMap<String, Object>()
chromePrefs.put("download.default_directory", downloadPath)
chromePrefs.put("download.prompt_for_download", false)
 
System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("prefs", chromePrefs)
WebDriver driver = new ChromeDriver(options)

https://docs.katalon.com/katalon-studio/tutorials/using_selenium_webdriver_katalon_studio.html#options-and-capabilities

1 Like

I was able to do this, here’s how I did it:

created a custom key word:

	 * download CSV to specified
	 */
	@Keyword
	public boolean isFileDownloaded(String downloadPath, String fileName) {

		File dir = new File(downloadPath);

		File[] dirContents = dir.listFiles();

		String lastAttempt = "";

		if (dirContents.length > 0) {

			for (int i = 0; i < dirContents.length; i++) {

				if (dirContents[i].getName().equals(fileName)) {

					// File has been found, it can now be deleted:

					dirContents[i].delete();

					KeywordUtil.markPassed(fileName + ' exist in ' + downloadPath + ' and was deleted')

					return true;

				}

				lastAttempt = dirContents[i].getName().equals(fileName);
			}

			if (lastAttempt != fileName) {

				KeywordUtil.markFailed(fileName + 'does not exist in' + downloadPath)

				return false;
			}
		}

		return false;
	}
}


then I invoked the keyword as follows in the test case:

WebUI.delay(2)
CustomKeywords.'com.company.katalon.cp.DataKeywords.isFileDownloaded'('C:\\Users', 'userlist.csv')```




this works in chrome with no issues. Hope this helps.

@marivic_e_lorilla thank you very much for this help! I inputted these into my desired capabilities, however, I am still not able to download files from chrome.

happy to help

First is have this setting in Chrome:

2nd is do what is told in this post

Of course, in your script, you should have a component to trigger the download
ie. a download button or if it is a pdf view mode, CTRL+S will do.
This step should be added to the test script steps such as below:
image

Glad to see that it works :grinning: