Adding Selenium Webdriver image download support

In the process of porting my iMacros macros over. One thing that is extremely vital to my workflow is the ability to download a image from a popup image box. The screenshot function does not work for me as the image is lower quality and has an ugly border. Automating the “save as” dialog also doesn’t work for me as the file I download is always renamed to the same name and using XType to navigate the overwrite dialog only works ~20% of the time.

My iMacros code snippet looked like this:

ONDOWNLOAD FOLDER=C:\filepath FILE=file1.jpeg WAIT=YES
TAG POS=1 TYPE=IMG ATTR=SRC:https://site.com/GetMedia.ashx?Key=*&Size=3* 
CONTENT=EVENT:SAVEITEM

It appears that it is possible to download the full image using WebDriver or urllib - there are multiple examples of the code on SO implementing this functionality. Is this something that I can implement in the UI.V interface or can be added? Or do I need to switch to full fledged selenium for this?

Examples:

Maybe lets focus on this first. It is usually the best option and works with 100% of all websites. Why would it work only 20% of the time? That surprises me.

Are you on Mac, Windows or Linux? Once I know, I will run a test.

A second option would be to extract the image URL from the website source code. => Is the image URL embedded in the page source code?

PS: Also, the iMacros SAVEITEM seems like a good idea. We might consider adding it.

Windows. It seems to have difficulty navigating the confirmation properly - sometimes it will hit “no” instead of yes or just not do anything. It may be some kind of timing issue wherein it will send the xtype command before the download dialog pops up.

Some more weird behavior that I noticed, not sure if intentional: For the same website, same element - In firefox, the click command does not work, but click and wait (without a value set) does. Click alone doesn’t seem to actually “press” the button. Whereas in chrome, neither of those work. I have to use XClick.

Regarding extracting the media URL: each photo has a unique key and is served up as presented in the URL above. They are reported to be jpeg format in the HTTP header. You do have to open the lightbox to get the URL to load in the page source but it is there.

The ability to save elements seems pretty basic to me. Why mess with automating the right-click-save-as dialog when you can just grab the element directly? And don’t even get me started on the weird scripts I’ve found on SO - who thought this was a good idea?

1 Like

There appears to be a solution now with SaveItem | Locator. Have not tested it yet personally.