I am comparing 2 PDF
- one (OriginalFile.pdf) that I have in Data Files
- 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:
- set download.prompt_for_download=true
- 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();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
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)
thanks