This section describes the procedure for downloading a file and checking the download results.
Download a file
Use the Click or Click and download file command.
How to use different commands
When testing only in Chrome, Firefox, or Edge, either Click or Click and download file is acceptable, and you do not need to do anything special about the download operation. For example, if you specify that you want to "Click" on some button, the download will be performed automatically.
In the case of IE, simply clicking a button for downloading does not allow the above keyboard operation, so a special the Click and download file command is used, since MagicPod does not know which button will trigger the download process, If you specify the Click and download file command in Chrome, Firefox, or Edge, the operation will be the same as Click, so you can use the same test case for IE and these browsers.
The behavior when a file download occurs during the operation under test will vary depending on the browser.
- In case of Chrome, Firefox, and Edge
- No download confirmation dialog is displayed, and the file is downloaded to a predetermined location (by default, the magicPod/downloads folder under the desktop).
- In case of IE11
- Since IE11 cannot automatically hide the confirmation dialog, the file is saved in the same folder as in Chrome, Firefox, and Edge using keyboard operation. This makes the operation slower than other browsers.
- It also tends to be more unstable than other browsers in terms of operation, so unless you have a special need to test downloads in IE, we recommend that you test in a different browser.
Check download result
Check of file name
Use the Assert download completed command.
To check if a file has been downloaded without problems, check if a file with a specific name is in the download folder. Regular expressions can be used for file names. (e.g. "data_file_ver2.txt", "data_file_ver.*\.txt", etc.)
Reference: Regular expressions
For example, the file name is “data_<date>.txt” such as “data_20241202.txt” and you want to assert the file name contains the test run date, you can use a combination of the “Date/Time Calculation” and “Confirm Downloaded” commands.
Note: Please be careful when running the test when the date changes, as the date may be different from the expected date and the test may fail.
If the file contains not only a date but also a time (e.g. data_20241202153045.txt), it is difficult to assert that the time is also equal to the expectation. (Because it is difficult to exactly match the time generated by MagicPod with the time contained in the filename generated by the application under test).
In such a case, please assert that the time part must be a 6-digit number using a regular expression as follows.
Check file contents (text files only)
Currently, MagicPod does not allow you to open downloaded files,
However, you can use the Store text file contents command to save the contents of a text file (TXT, CSV file) to a variable for confirmation or use. Regular expressions can be used for file names. (e.g. "data_file_ver2.txt", "data_file_ver.*.txt", etc.)
Waiting for time-consuming downloads
In case the file download seems as though it may take some time (10 seconds or more), enter the Wait until download completed command before the confirmation command. Regular expressions can be used for the filename here, too. If it finishes within 10 seconds, it will wait with the confirmation command alone, so you do not need to enter the wait command.
The final command will be as follows