You can use the following steps to confirm/verify download of a file using Google Chrome Browser:
#1. Wait for 5 seconds (Replace '5' with the required number of seconds for the download to complete)
#2. Open a new tab
#3. Go to chrome://downloads/
#4. If Verify that the current page displays text mailmerge.xls
----#5. Wait until the text Show in folder is present on the current page
You can use the above steps with just minor modifications for all the scenarios.
- Use a larger value for the wait time in seconds in the first step - We have used 5 seconds here.
- If you are on Mac, please change the verification text on step #5 to 'Show in finder' as shown below:
Wait until the text Show in finder is present on the current page
Given below is a sample Test Case containing steps for verifying a file download on Chrome:
Note: This is a workaround and quick solution for the file download verification conundrum in Test Automation.
A good rule of thumb is to download the file in tests if and only if we need to perform further checks on the downloaded file. In most cases, it is suggested to simply verify the download link with a get request. This is sufficient for testing the download function since the actions after clicking the download link are performed by the respective Web Browser and verifying the Web Browser functionality is out of scope for an Application specific Test Case.
Please check the below article for more justification - How To Download Files With Selenium And Why You Shouldn’t
Happy Smart Test Automation!