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.