Download file from web to desktop using Chrome

Hi all,

I am new to Katalon Studio. I can’t figure out how to download PDF file from web to my Downloads folder in windows.
When i click on download button, new chrome window is opened. In that window i have my pdf document. In top right corner there is this icon for file download. I wasn’t able to click on it, so i used sendKeys to simulate CTRL+S

WebUI.sendKeys(findTestObject(‘Page_f’), Keys.chord(Keys.CONTROL, ‘s’))

That worked but now i have another problem.
Windows explorer SAVE AS window pops up and i am not able to click on SAVE because this is windows native dialog.

How can i download pdf document?
Can i somehow simulate key press on SAVE button in windows dialog?

download.PNG

download_windows.PNG

I was able to solve it. I imported two java classes.

import java.awt.Robot;

import java.awt.event.KeyEvent;

and wrote this

Robot r = new Robot();

r.keyPress(KeyEvent.VK_ENTER);

r.keyRelease(KeyEvent.VK_ENTER);

And now this is what i have in my code:

WebUI.sendKeys(findTestObject(‘Page_f’), Keys.chord(Keys.CONTROL, ‘s’))

WebUI.delay(2)

Robot r = new Robot();

r.keyPress(KeyEvent.VK_ENTER);

r.keyRelease(KeyEvent.VK_ENTER);

Java Robot class is able to interact with windows native dialog.

See my comment in http://forum.katalon.com/discussion/4662/download-files-from-web-ui-not-working. You’ll no longer need robot.

1 Like

Marivic E. Lorilla said:

See my comment in Download files from web ui not working - Bugs Report - Katalon Community. You’ll no longer need robot.

I am using similar settings for chrome, but unable to download, Do i also need some code in this case other than settings…In my case file is getting opened in another chrome window where i have to click on download button to save it to a particular folder…Please help!

Am i missing something???

Untitled.png

screen.png

Hello, try to follow this post:

Marek Melocik said:

Hello, try to follow this post:

http://forum.katalon.com/discussion/comment/13052/#Comment_13052

Thanks Marek, not sure though how to use it…Can you share keyword for this?

There is a keyword called CustomChromeDriver, which contains one method. Just copy/paste it to your project and use in your test case (sample test case code is also there).

Thanks Marek, but in my case the download url is dynamic and it opens up in new chrome window…so how to make it work out in this case???

Thanks man! This works!

What is the - “Page_f”. I am trying to open the pdf page which opens in a new page and cannot get the locator of the download button.
So how can i write the sendkeys statement?

WebUI.sendKeys(null, Keys.chord(Keys.CONTROL,‘s’))

What should I put in place of null?