How to automatically collect the name of a recently downloaded file

If your scenario downloads a file but the file name is not always the same, you can follow the steps below to get the name of the recently downloaded file and assign it to a variable.

1. Click here to download a Jar 

2. Under Artifacts > File Uploads, upload the file you downloaded in step 1

3. Under Artifacts > Code Snippets, create a new Code Snippet

4. Enter a name for your snippet and click the magnifying glass icon next to Dependencies

5. Select the file that you uploaded in step 2

6. Save the Code Snippet

7. In your test case, create a step with Execute_Java command after the step that downloads the file and select the snippet from the dropdown list. 

8. In the Class, enter com.subject7.DownloadHelper and in the Method, enter getMostRecentFile

9. Execute your test case. Bear in mind that if the download will take a while, you should add a Wait step to allow the step enough time to execute. 

10. Once the step is executed, a variable will automatically be declared with the name DOWNLOAD_HELPER_MOST_RECENT_FILE that you can use anywhere else in your test case.

mceclip2.png

11. To use this in a Verify_File_Download step, you can use the variable name as the path. For example:

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.