The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "ONDOWNLOAD"
(39 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | iMacros automatically detects and intercepts downloads. | + | iMacros automatically detects and intercepts downloads. Use this command, which has to occur before the download starts, to determine the location and name of the saved file. |
− | The general web page timeout also applies to downloads. Make sure that the timeout value is long enough to cover the complete download time. | + | |
+ | == New for iMacros Browser 10.3 [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] == | ||
+ | |||
+ | <pre style="color: blue"> | ||
+ | The key differences between the old and the new download manager are: | ||
+ | |||
+ | * Rewritten download manager, better suited for mass-downloading and load testing. | ||
+ | * Download specific timeout command: !TIMEOUT_DOWNLOAD | ||
+ | * Web testing and transaction monitoring: In addition to checksum, we support now checks on file size inside the ONDOWNLOAD command | ||
+ | * Web scripting: File size and name are returned in the variables !DOWNLOADED_SIZE and !DOWNLOADED_FILE_NAME, respectively. | ||
+ | |||
+ | The new variables are supported in the iMacros Browser and iMacros for IE. We plan to support in Firefox and Chrome asap. | ||
+ | </pre> | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | The time taken for a file download is limited by [[!TIMEOUT_DOWNLOAD]]. If this value is not set in the macro, iMacros uses [[!TIMEOUT_PAGE]]. Make sure [[!TIMEOUT_DOWNLOAD]] is long enough to cover the complete download time, otherwise iMacros will stop with error = -1330: Page or Download Timeout. | ||
+ | |||
+ | If the macro ends before the download completes, but the browser is still open, the download continues but iMacros is no longer able to show errors which might arise because the download timed out. | ||
+ | |||
+ | The macro should still be running when the download starts, or iMacros cannot catch the download. Often websites need a few seconds for the download to start, so in case an ONDOWNLOAD command is present in a macro, but at macro playback end no download has started, iMacros will wait for up to an additional [[!TIMEOUT_STEP]] seconds before aborting with error -1410: No Download Detected. | ||
+ | |||
+ | === Syntax === | ||
+ | |||
+ | |||
+ | ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string] SIZE=n | ||
+ | |||
+ | -or- | ||
+ | |||
+ | ONDOWNLOAD CANCEL=YES | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | *FOLDER | ||
+ | *:Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options. | ||
+ | *:*Note that blank spaces in the path need to be replaced by <SP> like in c:\my<SP>folder, or surrounded with quotes (with backslashes escaped with another backslash) as in "c:\\my folder" | ||
+ | *FILE | ||
+ | *:Specifies the file name under which the file is saved. If no file extension is given, the server set default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension. | ||
+ | *:*Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable [[!NOW]] is helpful in this context. | ||
+ | *:*The full path of the downloaded file is stored in [[!DOWNLOADED_FILE_NAME]] | ||
+ | *WAIT | ||
+ | *:Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO). Default is NO | ||
+ | *[[CHECKSUM]] | ||
+ | *:Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. It requires WAIT=YES. | ||
+ | *SIZE | ||
+ | *:Compares the downloaded file size in bytes with the value specified. It requires WAIT=YES. | ||
+ | *:*If either CHECKSUM or SIZE is specified and does not match the values for the downloaded file in the disk, iMacros stops with error -1420: Checksum or Size Not Verified. iMacros also displays the calculated/measured value in the error message. Furthermore, you can retrieve the size of the downloaded file with the variable [[!DOWNLOADED_SIZE]] | ||
+ | *CANCEL | ||
+ | *:Stops automatic download from websites. | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | Suppose you download a file originally called setup.exe. The following snippet will save this file under the original file name in the default folder: | ||
+ | |||
+ | ONDOWNLOAD FOLDER=* FILE=* WAIT=YES | ||
+ | |||
+ | This command will save the file in the C:\MyFiles\ folder under the name myDownload.exe: | ||
+ | |||
+ | ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe WAIT=YES | ||
+ | |||
+ | And finally, this command will save the file in the default directory under the name with an added date stamp (using the [[!NOW]] variable), e.g. setup_141231.exe. | ||
+ | |||
+ | ONDOWNLOAD FOLDER=* <nowiki>FILE=+{{!NOW:yymmdd}}</nowiki> WAIT=YES | ||
+ | |||
+ | If you want to make sure that the downloaded file checksum matches the original MD5 checksum (say, CF78F0A6AFC3B5A37758BBBE04F61C9D) use | ||
+ | |||
+ | ONDOWNLOAD FOLDER=* FILE=* WAIT=YES CHECKSUM=MD5:CF78F0A6AFC3B5A37758BBBE04F61C9D | ||
+ | |||
+ | === Remarks === | ||
+ | |||
+ | [[File:DownloadManager.png|400px|thumb|iMacros Browser download manager]] | ||
+ | '''iMacros Browser 10.3 and above''' features a new download manager which deals with downloads during playback completely without dialogs. Download progress is shown on the status bar through a progress bar and a value indicating the size of the downloaded file. You can hover over this value to see the total size in bytes. Moreover, in iMacros log file you find | ||
+ | * the URL of the downloaded file, | ||
+ | * the size of downloded file, and | ||
+ | * the full path of the file in the disk. | ||
+ | |||
+ | The iMacros Browser download manager is able to download file types which are registered in the system to be open by an application (usually the case of PDF files), instead of opening them. There is no need to disable the application. | ||
+ | |||
+ | If you prefer the old download manager (dialogs) you can set [[!USE_DOWNLOADMANAGER]] NO in the macro before the ONDOWNLOAD command. | ||
+ | |||
+ | === Notes === | ||
+ | [[File:IE Prompt.png|200px|thumb|In IE, make sure "Always ask before opening this type of file" is not checked]] | ||
+ | # FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download. | ||
+ | # Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE. | ||
+ | # Blank spaces in the path need to be replaced by <SP> like in c:\my<SP>folder, or surrounded with quotes (with backslashes escaped with another backslash) as in "c:\\my folder" | ||
+ | # In Internet Explorer (but not the iMacros Browser) you need to enable the automatic prompting for downloads, to avoid the notification bar. | ||
+ | # Also in Internet Explorer, for some file types (e.g. zip and Excel files) you may need to change a setting to tell IE not to prompt to open the file. One has to first manually download such a file, then open the downloads view (Ctrl+J), right-click on the file to retrieve its context menu and disable "Always ask before opening this type of file" | ||
+ | # In Internet Explorer, while working with certain protocols especially FTP, there's a chance that the files get downloaded into the user's Downloads folder (e.g. C:\Users\<username>\Downloads) instead of the folder specified in the FILE parameter. | ||
+ | |||
+ | == iMacros for Firefox, Chrome and iMacros prior to 10.3 == | ||
+ | |||
+ | The general web page timeout also applies to downloads. Make sure that the timeout value is long enough to cover the complete download time. | ||
Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context. | Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context. | ||
Line 10: | Line 102: | ||
'''Important notes:''' | '''Important notes:''' | ||
− | * The maximum allowed download time is set by [[!TIMEOUT_PAGE]] (60s by default). So it is treated as page download (timeout wise). If you need to allow longer file downloads, please increase this value e. g. with SET ! | + | * The maximum allowed download time is set by [[!TIMEOUT_PAGE]] (60s by default). So it is treated as page download (timeout wise). If you need to allow longer file downloads, please increase this value e. g. with [[SET]] [[!TIMEOUT_PAGE]] 300. If the download is completed before 5 min (300s) are over, the macro continues. Otherwise you get a timeout error. |
* '''VERY IMPORTANT:''' '''The macro must still be running when the download dialog appears''', otherwise iMacros can not catch it. Often websites need a few seconds for the download to start, so make sure the macro is still active then, e. g. by adding a short wait statement at the end. This wait time is not for the download itself, but only for the time the site needs for the download dialog to appear. If the macro continues with other commands, you will not need such a WAIT statement, you need it only when the download is at the end of the macro. | * '''VERY IMPORTANT:''' '''The macro must still be running when the download dialog appears''', otherwise iMacros can not catch it. Often websites need a few seconds for the download to start, so make sure the macro is still active then, e. g. by adding a short wait statement at the end. This wait time is not for the download itself, but only for the time the site needs for the download dialog to appear. If the macro continues with other commands, you will not need such a WAIT statement, you need it only when the download is at the end of the macro. | ||
Line 20: | Line 112: | ||
WAIT SECONDS=1 | WAIT SECONDS=1 | ||
+ | * If the download does not start before the end of the macro, iMacros will wait for up to an additional [[!TIMEOUT_STEP]] seconds before aborting with error -1410: No Download Detected. | ||
---- | ---- | ||
− | === Syntax [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] === | + | === Syntax [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]=== |
ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string] | ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string] | ||
− | + | ||
+ | -or- | ||
+ | |||
ONDOWNLOAD CANCEL=YES | ONDOWNLOAD CANCEL=YES | ||
Line 38: | Line 133: | ||
*:Specifies the file name under which the file is saved. If no file extension is given, the default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension. | *:Specifies the file name under which the file is saved. If no file extension is given, the default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension. | ||
*WAIT | *WAIT | ||
− | *:Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO), Default is | + | *:Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO), Default is YES |
*[[CHECKSUM]] | *[[CHECKSUM]] | ||
*:Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. Note: [[CHECKSUM]] requires WAIT=YES. | *:Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. Note: [[CHECKSUM]] requires WAIT=YES. | ||
+ | *CANCEL [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] | ||
+ | *:Stops automatic download from websites. Note, the CANCEL parameter is implemented in versions above iMacros v9.01 and is not available in iMacros for Firefox and Chrome ''yet''. | ||
=== Examples === | === Examples === | ||
Line 71: | Line 168: | ||
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES CHECKSUM=SHA1:3FD97C2EC475731997F7F28CB5C07F3D1A1E820A | ONDOWNLOAD FOLDER=* FILE=* WAIT=YES CHECKSUM=SHA1:3FD97C2EC475731997F7F28CB5C07F3D1A1E820A | ||
+ | In case you want to avoid (single or multiple) automatic downloads, you can make use of the CANCEL parameter. The CANCEL parameter can be specified only when other parameters are omitted and is effective until one of the following commands occurs: ONDOWNLOAD CANCEL=NO, or ONDOWNLOAD FOLDER=... FILE=... | ||
+ | |||
+ | ONDOWNLOAD CANCEL=YES | ||
+ | |||
Example macros: Demo-FileDownload, Demo-ImageDownload | Example macros: Demo-FileDownload, Demo-ImageDownload | ||
Line 82: | Line 183: | ||
See also: [http://forum.iopus.com/viewtopic.php?p=5991 Prevent IE from opening PDFs] | See also: [http://forum.iopus.com/viewtopic.php?p=5991 Prevent IE from opening PDFs] | ||
− | Website for testing: [http:// | + | Website for testing: [http://demo.imacros.net/Automate/PDFdemo PDF Download Test] |
=== Notes === | === Notes === | ||
Line 95: | Line 196: | ||
<li>In '''Internet Explorer''' (but not the iMacros Browser) you need to [[IE_Nags#How_to_enable_the_automatic_prompting_for_downloads_.28avoid_notification_bar.29.3F|enable the automatic prompting for downloads, to avoid the notification bar.]]</li> | <li>In '''Internet Explorer''' (but not the iMacros Browser) you need to [[IE_Nags#How_to_enable_the_automatic_prompting_for_downloads_.28avoid_notification_bar.29.3F|enable the automatic prompting for downloads, to avoid the notification bar.]]</li> | ||
<li>It is highly necessary to have the option to hide file extensions (in Windows Explorer) disabled! Otherwise, iMacros may fail to rename the file when specifying something other than the original file name (e.g. when not using the default FILE=*). | <li>It is highly necessary to have the option to hide file extensions (in Windows Explorer) disabled! Otherwise, iMacros may fail to rename the file when specifying something other than the original file name (e.g. when not using the default FILE=*). | ||
+ | <li>FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.</li> | ||
+ | <li>Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.</li> | ||
</ol> | </ol> | ||
Line 105: | Line 208: | ||
* [http://forum.iopus.com/viewtopic.php?f=6&t=12790 How to determine iMacros folder locations from VBScript] | * [http://forum.iopus.com/viewtopic.php?f=6&t=12790 How to determine iMacros folder locations from VBScript] | ||
− | + | == See Also == | |
− | + | [[CHECKSUM]], [[!TIMEOUT_DOWNLOAD]], [[!DOWNLOADED_SIZE]], [[!DOWNLOADED_FILE_NAME]], [[!USE_DOWNLOADMANAGER]] |
Revision as of 12:08, 28 June 2017
iMacros automatically detects and intercepts downloads. Use this command, which has to occur before the download starts, to determine the location and name of the saved file.
New for iMacros Browser 10.3
The key differences between the old and the new download manager are: * Rewritten download manager, better suited for mass-downloading and load testing. * Download specific timeout command: !TIMEOUT_DOWNLOAD * Web testing and transaction monitoring: In addition to checksum, we support now checks on file size inside the ONDOWNLOAD command * Web scripting: File size and name are returned in the variables !DOWNLOADED_SIZE and !DOWNLOADED_FILE_NAME, respectively. The new variables are supported in the iMacros Browser and iMacros for IE. We plan to support in Firefox and Chrome asap.
The time taken for a file download is limited by !TIMEOUT_DOWNLOAD. If this value is not set in the macro, iMacros uses !TIMEOUT_PAGE. Make sure !TIMEOUT_DOWNLOAD is long enough to cover the complete download time, otherwise iMacros will stop with error = -1330: Page or Download Timeout.
If the macro ends before the download completes, but the browser is still open, the download continues but iMacros is no longer able to show errors which might arise because the download timed out.
The macro should still be running when the download starts, or iMacros cannot catch the download. Often websites need a few seconds for the download to start, so in case an ONDOWNLOAD command is present in a macro, but at macro playback end no download has started, iMacros will wait for up to an additional !TIMEOUT_STEP seconds before aborting with error -1410: No Download Detected.
Syntax
ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string] SIZE=n
-or-
ONDOWNLOAD CANCEL=YES
Parameters
- FOLDER
- Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options.
- Note that blank spaces in the path need to be replaced by <SP> like in c:\my<SP>folder, or surrounded with quotes (with backslashes escaped with another backslash) as in "c:\\my folder"
- Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options.
- FILE
- Specifies the file name under which the file is saved. If no file extension is given, the server set default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension.
- Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context.
- The full path of the downloaded file is stored in !DOWNLOADED_FILE_NAME
- Specifies the file name under which the file is saved. If no file extension is given, the server set default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension.
- WAIT
- Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO). Default is NO
- CHECKSUM
- Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. It requires WAIT=YES.
- SIZE
- Compares the downloaded file size in bytes with the value specified. It requires WAIT=YES.
- If either CHECKSUM or SIZE is specified and does not match the values for the downloaded file in the disk, iMacros stops with error -1420: Checksum or Size Not Verified. iMacros also displays the calculated/measured value in the error message. Furthermore, you can retrieve the size of the downloaded file with the variable !DOWNLOADED_SIZE
- Compares the downloaded file size in bytes with the value specified. It requires WAIT=YES.
- CANCEL
- Stops automatic download from websites.
Examples
Suppose you download a file originally called setup.exe. The following snippet will save this file under the original file name in the default folder:
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES
This command will save the file in the C:\MyFiles\ folder under the name myDownload.exe:
ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe WAIT=YES
And finally, this command will save the file in the default directory under the name with an added date stamp (using the !NOW variable), e.g. setup_141231.exe.
ONDOWNLOAD FOLDER=* FILE=+{{!NOW:yymmdd}} WAIT=YES
If you want to make sure that the downloaded file checksum matches the original MD5 checksum (say, CF78F0A6AFC3B5A37758BBBE04F61C9D) use
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES CHECKSUM=MD5:CF78F0A6AFC3B5A37758BBBE04F61C9D
Remarks
iMacros Browser 10.3 and above features a new download manager which deals with downloads during playback completely without dialogs. Download progress is shown on the status bar through a progress bar and a value indicating the size of the downloaded file. You can hover over this value to see the total size in bytes. Moreover, in iMacros log file you find
- the URL of the downloaded file,
- the size of downloded file, and
- the full path of the file in the disk.
The iMacros Browser download manager is able to download file types which are registered in the system to be open by an application (usually the case of PDF files), instead of opening them. There is no need to disable the application.
If you prefer the old download manager (dialogs) you can set !USE_DOWNLOADMANAGER NO in the macro before the ONDOWNLOAD command.
Notes
- FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.
- Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.
- Blank spaces in the path need to be replaced by <SP> like in c:\my<SP>folder, or surrounded with quotes (with backslashes escaped with another backslash) as in "c:\\my folder"
- In Internet Explorer (but not the iMacros Browser) you need to enable the automatic prompting for downloads, to avoid the notification bar.
- Also in Internet Explorer, for some file types (e.g. zip and Excel files) you may need to change a setting to tell IE not to prompt to open the file. One has to first manually download such a file, then open the downloads view (Ctrl+J), right-click on the file to retrieve its context menu and disable "Always ask before opening this type of file"
- In Internet Explorer, while working with certain protocols especially FTP, there's a chance that the files get downloaded into the user's Downloads folder (e.g. C:\Users\<username>\Downloads) instead of the folder specified in the FILE parameter.
iMacros for Firefox, Chrome and iMacros prior to 10.3
The general web page timeout also applies to downloads. Make sure that the timeout value is long enough to cover the complete download time.
Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context.
iMacros can calculate the checksum of a downloaded file and compare it with the value of the CHECKSUM parameter. This is very useful to verify that file downloads are not corrupted, or worse, have been infected by a virus or trojan horse (e. g. via a hacked server). Both the MD5 and the SHA1 checksums are supported.
Important notes:
- The maximum allowed download time is set by !TIMEOUT_PAGE (60s by default). So it is treated as page download (timeout wise). If you need to allow longer file downloads, please increase this value e. g. with SET !TIMEOUT_PAGE 300. If the download is completed before 5 min (300s) are over, the macro continues. Otherwise you get a timeout error.
- VERY IMPORTANT: The macro must still be running when the download dialog appears, otherwise iMacros can not catch it. Often websites need a few seconds for the download to start, so make sure the macro is still active then, e. g. by adding a short wait statement at the end. This wait time is not for the download itself, but only for the time the site needs for the download dialog to appear. If the macro continues with other commands, you will not need such a WAIT statement, you need it only when the download is at the end of the macro.
Example:
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES URL GOTO= http://www.opera.com/download/get.pl?id=32799&location=326¬hanks=yes&sub=marine 'Wait for download to _start_, afterwards iMacros waits for the completion automatically WAIT SECONDS=1
- If the download does not start before the end of the macro, iMacros will wait for up to an additional !TIMEOUT_STEP seconds before aborting with error -1410: No Download Detected.
Syntax
ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string]
-or-
ONDOWNLOAD CANCEL=YES
Parameters
- FOLDER
- Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options.
- Note that blank spaces in the path need to be replaced by "<SP>" like in "c:\my<SP>folder" (instead of "c:\my folder")
- FILE
- Specifies the file name under which the file is saved. If no file extension is given, the default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension.
- WAIT
- Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO), Default is YES
- CHECKSUM
- Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. Note: CHECKSUM requires WAIT=YES.
- CANCEL
- Stops automatic download from websites. Note, the CANCEL parameter is implemented in versions above iMacros v9.01 and is not available in iMacros for Firefox and Chrome yet.
Examples
Suppose you download a file originally called setup.exe. The following snippet will save this file under the original file name in the default folder:
ONDOWNLOAD FOLDER=* FILE=*
This command will save the file in the C:\MyFiles\ folder under the name myDownload.exe:
ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe
And finally, this command will save the file in the default directory under the name with an added date stamp (using the !NOW variable), e.g. setup_060525.exe.
ONDOWNLOAD FOLDER=* FILE=+{{!NOW:yymmdd}}
Note: The "+" symbol is only required if you want to add text to the default file name (as created by the website). In this case, "+" must be the first symbol, directly after FILE=+... . The "+" is not required (and not allowed) if you want to concatenate several variables. To concatenate variables just use them as part of the string. Example: FILE=invoice_no{{number}}_unit{{departement}}.pdf
You can verify the integrity of the downloaded file using the CHECKSUM parameter. Here the expected checksum was previously calculated as a hexadecimal string using the SHA-1 function.
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES CHECKSUM=SHA1:3FD97C2EC475731997F7F28CB5C07F3D1A1E820A
In case you want to avoid (single or multiple) automatic downloads, you can make use of the CANCEL parameter. The CANCEL parameter can be specified only when other parameters are omitted and is effective until one of the following commands occurs: ONDOWNLOAD CANCEL=NO, or ONDOWNLOAD FOLDER=... FILE=...
ONDOWNLOAD CANCEL=YES
Example macros: Demo-FileDownload, Demo-ImageDownload
PDF Downloading
Please make sure you uninstall or disable PDF handling browser addons, such as Adobe. Then the browser prompts you to download the PDF as regular download - and iMacros can automate it.
See also: Prevent IE from opening PDFs
Website for testing: PDF Download Test
Notes
- The download dialog needs a short while to appear after it is triggered and iMacros should to be running to catch it. If the macro ends right after the command which triggers the download, iMacros will not be able to catch the dialog. In this case, we suggest adding
WAIT SECONDS=2
- after the command which triggers the download. This gives iMacros time to wait for the dialog.
- The parameter WAIT=YES refers to another waiting, namely after the download has started it should wait for the download to complete.
- In Internet Explorer (but not the iMacros Browser) you need to enable the automatic prompting for downloads, to avoid the notification bar.
- It is highly necessary to have the option to hide file extensions (in Windows Explorer) disabled! Otherwise, iMacros may fail to rename the file when specifying something other than the original file name (e.g. when not using the default FILE=*).
- FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.
- Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.
Related Forum Posts
For iMacros for Firefox:
- Tips for downloading files with ONDOWNLOAD Describes issues specific to some Firefox settings.
Other:
See Also
CHECKSUM, !TIMEOUT_DOWNLOAD, !DOWNLOADED_SIZE, !DOWNLOADED_FILE_NAME, !USE_DOWNLOADMANAGER