Error using ONDOWNLOAD

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Waddle
Posts: 5
Joined: Wed Nov 17, 2010 6:01 am

Error using ONDOWNLOAD

Post by Waddle » Wed Nov 17, 2010 6:59 am

First off, thanks for this awesome tool!

I'm trying to automate the Google adwords tool with imacros for Firefox (Firefox 3.6.12, imacros 7.0.3.0 on Mac OS X Snow Leopard 10.6.4 with no other plugins running). Specifically, the adwords tool allows you to download your list of keywords in a csv file and this is where imacros is failing. I have set up an ONDOWNLOAD command in my script, but imacros just pops up the save-as dialog ("You have chosen to open..." along with the open or save options) and then hangs. Instead of saving the file with my filename, I get the error:

Code: Select all

RuntimeError: ONDOWNLAD command was used but no downalod occurred.
The Demo-Download.iim file also shows that same problem.

I have also tried this on windows and I have the same problem.

The situation is slightly tricky because the download is triggered by clicking on an ajax button. However, it is definitely successfully being triggered by imacros, since the save-as dialog pops up; it's just that imacros isn't catching the download with the ONDOWNLOAD command.

The code I'm using for the download is:

Code: Select all

' Click download
TAG POS=1 TYPE=DIV ATTR=ID:gwt-debug-tableHeader-downloadDropSelection-content
' Click download all
TAG POS=1 TYPE=DIV ATTR=ID:gwt-debug-tableHeader-downloadAllItem
' Click download as CSV
TAG POS=1 TYPE=SELECT ATTR=ID:gwt-debug-downloadPopup-format-dropdown CONTENT=%CSV

' Download the file
ONDOWNLOAD FOLDER=* FILE=football.csv WAIT=YES
TAG POS=1 TYPE=SPAN ATTR=ID:gwt-debug-downloadPopup-download-button-content
' Wait to catch the download
WAIT SECONDS=12
Any ideas how to get around this and download the csv file without having to type or click anything extra?
Waddle
Posts: 5
Joined: Wed Nov 17, 2010 6:01 am

Re: Error using ONDOWNLOAD

Post by Waddle » Wed Nov 17, 2010 7:24 am

I have made some progress. I reset the option to automatically download CSV files in Firefox back to the default, and then switched it back on again. I also added this line to my script:

Code: Select all

SET !ERRORIGNORE YES
and now I can successfully download the csv file!

However, unfortunately the file is saved with the default name rather than the name I specify in my ONDOWNLOAD command. This happens on both OS X and Windows.Any clues on how to make sure imacros saves the file with the correct name?

One possible workaround would be to open Firefox and imacros from the command line, run the macro, and then rename the file from the shell before moving on to the next macro. However, I can't work out how to successfully open Firefox and run a macro from the command line on OS X.
Waddle
Posts: 5
Joined: Wed Nov 17, 2010 6:01 am

Re: Error using ONDOWNLOAD

Post by Waddle » Wed Nov 17, 2010 11:17 am

A bit more info. I uninstalled 7.0.3.0 and tried using 7.0.2 and 6.7.1. They both showed the same problem - hanging on the save-as download dialog. I reinstalled 7.0.3.0 and much to my disgust the same thing happened! The solution was to open about:config, search for 'download' and set all the options that I had customized to their defaults. This allowed me to use ONDOWNLOAD to automatically download files again, although the FILE and FOLDER options still have no effect - any file using imacros gets saved as its default name in the default imacros download directory.
Tom, Tech Support
Posts: 3705
Joined: Mon May 31, 2010 4:59 pm

Re: Error using ONDOWNLOAD

Post by Tom, Tech Support » Wed Nov 24, 2010 3:53 pm

Hi Waddle,

Can you try changing the ONDOWNLOAD command in the Demo-Download macro that comes with iMacros to specify your own file name and folder and let me know if it works?
Regards,

Tom, iMacros Support
Waddle
Posts: 5
Joined: Wed Nov 17, 2010 6:01 am

Re: Error using ONDOWNLOAD

Post by Waddle » Wed Nov 24, 2010 10:18 pm

Thanks for your reply Tom.

I just tried that and no matter what combinations of FOLDER= and FILE= I try, the file always gets downloaded to my default downloads directory with the default filename. Also, the only way to make the file download automatically at all (without the appearance of the 'save as' dialog) is to manually reset my download settings in about:config before each imacros session.

I have temporarily worked around the problem by calling a php script (running on localhost and launched in another tab) after each download, to move and rename the file from my default downloads directory to where I want it to go.
Tom, Tech Support
Posts: 3705
Joined: Mon May 31, 2010 4:59 pm

Re: Error using ONDOWNLOAD

Post by Tom, Tech Support » Fri Nov 26, 2010 6:13 pm

I'm glad you have a workaround. I believe the issue is definitely related to how you have your instance of Firefox configured, because on a stock installation of Firefox and iMacros for Firefox, you can edit and run the Demo-Download macro and save the file to a user-specified folder with a user-specified name.
Regards,

Tom, iMacros Support
Tom, Tech Support
Posts: 3705
Joined: Mon May 31, 2010 4:59 pm

Re: Error using ONDOWNLOAD

Post by Tom, Tech Support » Tue May 17, 2011 12:43 am

UPDATE: Additional information regarding this topic can be found in Tips for downloading files with ONDOWNLOAD.
Regards,

Tom, iMacros Support
JJS2421
Posts: 1
Joined: Sat Feb 01, 2014 11:05 pm

Re: Error using ONDOWNLOAD

Post by JJS2421 » Sun Feb 02, 2014 1:24 am

I have found a good way to get the download and set it for present date and it is downloaded in a folder of your naming under a specific path shown here:
ONDOWNLOAD FOLDER=Macros<SP>Downloads FILE=+{{!NOW:ddmmyyyy}} WAIT=YES
SAVEAS TYPE=PNG FOLDER=C:\Users\Macros<SP>Downloads\WWWDOTD_{{!NOW:mmddxxyy}} FILE=+{{!NOW:mmddxxyy}}_Deal_1

Here : ONDOWNLOAD needs to be before every instance of SAVEAS, not at the beginning of code only. The Users path is set for anyone to use it if they have a folder named "Macros Downloads" just in the users file of any computer. The !NOW settings are good for today's date and the name " Deal_1" is the name I set for the screenshot.

Hope this helps anyone
Post Reply