determine file name of downloaded file
Hi all,
I'm trying to confirm that the contents of my CSV exports are as expected. Or conversely, export the data from my application to check the application data is correct by checking the CSV results. This works better than Database checks for some situations, since the CSV eport can do all the object property lookups with multiple database calls etc. I have all the required tools through DataDrivers/ADO to read through the csv/xls etc. What I'm finding a challenge is finding resources that can help me find the path and filename of the last download. I have tried solutions described in thread
and
https://support.smartbear.com/viewarticle/8999/
Both these resources however assume you are trying to download an existing file to your machine. I'm trying to get a CSV/XLS that gets generated and uniquely named when you click the "Export" button. I'm sure it's been done before. Are there any other resources I haven't found yet you know of ?
Something like https://support.smartbear.com/viewarticle/51660/
but I do testing in IE and I'm not clear exactly how I'm going to extract the file name from there...
You should be able to use https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/savefile-method-window-object.html when you export / save and specify your path and file name.
Alternatively, you could use https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/methods.html and https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfilesystem/methods.html to determine the newest file in your download directory.
My guess is that it exports/downloads to the default "Downloads" folder for the currently logged in user. So, you can do something like %AppData% to get the pathing to start with.
As for the filename, It might not be a matter of filename, but more on the lines of just detecting the CSV/XLS file with the most recent date/time stamp. Look into using aqFileSystem to determine that.
I would also suggest, in order to make that easier, at the end of the test, delete all CSV/XLS files from that folder or at least move them to an archive place. That way, when you do the export, the ONLY file in that downloads folder will be the one you want... and the specific filename itself won't matter.