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
- The file is downloaded automatically without displaying a download confirmation dialog.
- In case of IE11
- Since IE11 cannot automatically hide the confirmation dialog, the file is saved using keyboard operations. 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.
File download location
- In case of Cloud Browser Environment
- Downloaded files are temporarily saved in a storage folder within the cloud environment. However, users cannot access or view these files directly.
- This storage folder is reset to an empty state before running a test case on the test case edit page or starting a batch run.
- In case of Local PC Environment
- Downloaded files are saved in a storage folder on the local PC.
- By default, this folder is located under "Desktop/magicPod/downloads". You can change the download location by specifying a full path for the "workDir" property in the "magic_pod_config.json" file.
- This local folder is also cleared before each test run.
- If multiple files with the same name are downloaded during a single test run, the browser will rename them by appending a serial number.
The naming format varies by browser and OS. (In Chrome, a space is added before the number.)
Examples:
・On Mac Chrome: "download_file (1).zip" , "download_file (2).zip" ...
・On Mac Firefox: "download_file(1).zip" , "download_file(2).zip" ...
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