alternative way for setting the name of a file to download without using java.awt.Robot

I am comparing 2 PDF

  1. one (OriginalFile.pdf) that I have in Data Files
  2. one that I am downloading during the test (MyFileName.pdf) in the home/downloads folder.

Of course for comparing the files, I need to capture the name of the file that I am downloading to then enter the name as a parameter for katalon.keyword.pdf.PDF.compareAllPages.

For doing this I have:

  1. set download.prompt_for_download=true
  2. use java.awt.Robot to set the name of my file.

The question:
since Robot is giving me many problems during the console execution of the test. I would like to know if there is way to set the name of my file before (or during) download without using Robot, so that probably I would not even have to download.prompt_for_download=true

my actual code during “Saving the file” and then “Compare files” is like this for sure:

String FileName = ‘MyFileName’
StringSelection stringSelection = new StringSelection(MyFileName);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection);

	Robot robot = new Robot();

String path = RunConfiguration.getProjectDir() + “/Data Files/”
home = System.getProperty(‘user.home’)
String userDownloads = new File(home + ‘/Downloads/’ + ‘MyFileName’ + “.pdf”)

assert CustomKeywords.‘com.kms.katalon.keyword.pdf.PDF.compareAllPages’(path+ “OriginalFile.pdf”, userDownloads,null)