Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webdriver | IE9 | Setup auto-download files

I need to test download action. I've already configured remote webdrivers for FF and Chrome browsers to download files automatically without any promts and popup-windows. But I can not find any useful information - how to allow file auto-downloading for IE9.

What I've tried:

  • find any possible ways to configure Driver itself. Found nothing: no capabilities, no options, no cmd args
  • find settings in Security tab. I have checked it already and found that settings to allow this was removed for IE9.
  • use such registry keys, but it doesn't help (found it here):

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2202=0x0

and this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_RESTRICT_FILEDOWNLOAD\iexplore.exe=0x00000000

Who knows how to solve it? Is it real?

like image 850
Gadget Avatar asked Oct 21 '22 18:10

Gadget


1 Answers

Unfortunately, I have also hit this problem recently. I am afraid to say it is not good news.

IE8 and below, this was different, simply because it was a new window you could interact with.

IE9, it is now a builtin 'Frame Notification Bar'

You can click the Save button using PInvoke... see this topic:

https://stackoverflow.com/a/8532222/1173729

That answer is for Watin, but the only difference it that Watin already encapsulates the ability to get the handle of a particular browser window. This can simply be switched with your own method, the point is generally just get the handle of IE's window, walk down it's child elements until you hit a 'Save' button. This has a major drawback though, switching the control back to Selenium - it doesn't happen, Selenium will just hang.

Note, this is all in C#. Java apparently has other ways, like the 'Robot' class:

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html

I have not used them, but you will be able to use the class to direct it to where the Save button will be.

There will be no registry keys or settings to avoid this problem - it is simply not possible.

I have taken the decision that since FF & Chrome can be set up to automatically download a file, you can verify it's existence afterwards. You test that the file can be downloaded and it shows up on the hard drive.

What are the chances that won't happen in IE9, if it works OK in Chrome and Firefox? Slim, but possible.

The bottom line is it's an OS dialog, something outside of the scope of Selenium.

You can also combine it with AutoIT. My experience is AutoIT can also be just as flaky.

like image 75
Arran Avatar answered Oct 28 '22 21:10

Arran