Is this possible to use Katalon to download a file?

Is this possible to use Katalon to download a file?

I’ve already tried:
Download file from web to desktop using Chrome
Identifying Chrome download box
Downloading the files in headless chrome
https://docs.katalon.com/katalon-studio/docs/introduction-to-desired-capabilities.html#firefoxfirefox-headless

Hi @gdearest07,
my working config for download by Firefox.

1 Like

Is there any way to download a file in Katalon?

I’ve been trying to download a pdf file by using Katalon for quite a while but hasn’t been able to do it so far. I’ve tried
Download file from web to desktop using Chrome
Identifying Chrome download box
Downloading the files in headless chrome
https://docs.katalon.com/katalon-studio/docs/introduction-to-desired-capabilities.html#firefoxfirefox-headless

Interesting enough, I had a choice which automation tool to use and I choose KSE. If it’s impossible to use KSE for such a simple task as file downloading then I should’ve chosen UFT.

@gdearest07

To download pdf file in Chrome automatically using Selenium. You should configure these capabilities:

{
  "prefs": {
    "download.default_directory": "Your download folder",
    "download.directory_upgrade": true,
    "download.prompt_for_download": false,
    "plugins.always_open_pdf_externally": true,
    "profile.default_content_settings.popups": "0",
    "profile.content_settings.exceptions.automatic_downloads.*.setting": "1"
  },
  "args": [
    "--no-sandbox",
    "--disable-dev-shm-usage"
  ],
  "useAutomationExtension": "false"
}


Please clone this sample project and change the “download.default_directory” to your desired folder and run a sample test case: https://github.com/duyluonganh/kat-download-file

Thanks

4 Likes
2 Likes

Hi, @duyluong.

Thanks a lot for your help! Your solution seems to be the only solutions that works.

I’d just like to use this opportunity to ask a couple of questions. My understanding is that the following is just a typo:

“prefs”: {
"browser.download.manager.showWhenStartingbrowser.download.manager.showWhenStarting": “false”,

When I put just browser.download.manager.showWhenStartingbrowser, it still works. Does it mean that this preference is not really needed?

Also, could you please let us know when did you get the info on which capabilities should be used and what those capabilities mean? I’ve spent a lot of time trying to find the right capabilities but whatever I found wasn’t working.

And last but not least, do you happen to know whether it’s possible to download a pdf file (the only pdf file on the page) w/o clicking on it? Thanks again!

Thank you for your help, Milan Chalánek.

For some reasons, your solution doesn’t seem to be working for me. I’ve tried this:

but the file was not downloaded and I was just seeing the following :

when I was running the sample pdf test case duyluong provided in https://github.com/duyluonganh/kat-download-file

Thank you for your help, discover.selenium.

For some reasons, your solution doesn’t seem to be working for me. I’ve tried this:


image

but the file was not downloaded and I was just seeing the following :

when I was running the sample pdf test case duyluong provided in https://github.com/duyluonganh/kat-download-file

@gdearest07
"browser.download.manager.showWhenStartingbrowser.download.manager.showWhenStarting"

Yep, this desired capability is unnecessary. Just a typo mistake.

To apply with Firefox, you should use these capabilities:

{
  "moz:firefoxOptions": {
    "prefs": {
      "browser.helperApps.neverAsk.saveToDisk": "application/vnd.ms-excel, application/pdf",
      "pdfjs.disabled": true,
      "browser.download.dir": "Your download folder",
      "browser.download.folderList": 2
    }
  }
}


I also updated my repo with the Firefox desired capabilities. You can pull the code and run the sample test.

Also, could you please let us know when did you get the info on which capabilities should be used and what those capabilities mean? I’ve spent a lot of time trying to find the right capabilities but whatever I found wasn’t working.

Chrome and Firefox provide their desired capabilities at their website, you should read these documents first:


Next step, you need to search in the Selenium communities about this issue and realize the problem here. Eg:


  • When clicking on a normal file (not pdf), Chrome and Firefox will ask to download the file. You need to find the desired capability to tell the browser don’t ask about to download.
  • When clicking on a pdf file, Chrome and Firefox will display the file using the pdf viewer. You need to find the desired capability to tell the browser to treat the pdf as a normal file.

During the test, you should open Chrome settings and Firefox about:config to check that all desired capabilities have been recognised by the browser.

1 Like

@duyluong, thanks a lot for your help, the updated repo and detailed reply!

It does work when I use these capabilities in Desired Capabilities -> Web UI -> Firefox (as it’s shown in your screenshots).

However, when I try to use the very same capabilities in Desired Capabilities -> Custom, it doesn’t seem to be working because the Windows dialog appears :

Is this a bug or feature (or perhaps it should be done differently)? Thanks.

Download Katalon Studio by signing up for a free account at Katalon’s website. After installation, login to the Katalon Studio using your account credentials and create a new Sample Android Mobile Tests Project. The process has been detailed for the sample app and test cases provided by Katalon, you can replace the app with your own app and make changes in your test cases accordingly.

sample_project

Set the project name in the ‘Name’ field and click OK

name

In the Tests Explorer window go to the folder androidapp → APIDemos.apk. This is the application which will be tested on BrowserStack.

test_explorer

Upload app on the BrowserStack server
Upload APIDemos.apk to BrowserStack using your account credentials (Username and Access Key). The REST API is:

curl -u “YOUR_USERNAME:YOUR_ACCESS_KEY”
-X POST “https://api-cloud.browserstack.com/app-automate/upload
-F “file=@/path/to/app/file/APIDemos.apk”
-F “custom_id=MyApp”
Sample Response:

{“app_url”:“bs://f7c874f21852ba57957a3fdc33f47514288c4ba4”, “custom_id”:“MyApp”,“shareable_id”:"YOUR_USERNAME/MyA

Awesome.Your project helped me to resolve the issue.Thanks alot @duyluong

1 Like