Files are not downloaded even if the download button has been clicked

Hi,

I would like to download a file by clicking on the “Download” button as seen in the screenshot. My script is able to run successfully but the file just won’t get downloaded to my default “Downloads” folder. If I clicked the “Download” button manually, I’m able to download the file successfully.

I’ve also set my Firefox profile as below:

My script is as below:

WebUI.click(findTestObject(‘Download/button_Download’))

Runtime.getRuntime().exec(‘C:\\Users\Desktop\\AutoIt\\Send Arrow Down and Enter.exe’)

WebUI.delay(3)

Runtime.getRuntime().exec(‘C:\\Users\\Desktop\\AutoIt\\Send Esc.exe’)

WebUI.delay(5)

Kindly help me on this issue. Thanks.

Download.PNG

Firefox Settings.PNG

This gets tricky and the only way I have been able to do something like this was when I verify what was downloaded. The application I am in doesn’t ask me where I want to save. However when I validate I have to dynamically look based upon the user running the script…Hopefully this helps?

I put this in the test case:

String home = System.getProperty(‘user.home’)

String userDownloads = new File(home + ‘/Downloads/’)

I also created a method under custom keywords I call in to verify:

package customKeywords

import com.kms.katalon.core.annotation.Keyword

import com.kms.katalon.core.util.KeywordUtil

import org.testng.Assert

@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;

}

I’m not sure if this will be of use to you or not, but I’m hoping you can play with the home and download path.