locked
How to disable the "Open or Save prompt" in IE when downloading a file? I want the files to be saved automatically RRS feed

  • Question

  • Hi,

    I am working on an Automation project where I download some files. I work with C# and Selenium.

    When I use IE, I get this prompt asking whether to save the file or Open the file every time whenever a download.

    I want the files to be saved automatically without any manual intervention.

    Is there a setting in IE or can this be done through C#?

    I am okay with registry entries solutions also, if any.

    -Note: I am using the latest IE 11.

    Thanks,

    Saranya

    Wednesday, April 15, 2020 5:24 AM

Answers

  • Hi Saranya Madhusudhan,

    Yes, Autoit code can help you to automate that Save Open popup.

    The Autoit is a third party product and I am not familiar with it.

    Autoit has a forum support. I suggest you raise a question there.

    Autoit forums

    Thank you for your understanding.

    Regards,

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, April 15, 2020 1:39 PM
  • Hi Deepak,

    Thank you for pointing me to the right forum, I have got the logic. 

    I am posting it here if someone needs it.

                var winHandle = AutoItX.WinGetHandle("[Class:IEFrame]");
                var ctrlHandle = AutoItX.ControlGetHandle(winHandle, "[Class:DirectUIHWND]");
                var ctrlPos = AutoItX.ControlGetPos(winHandle, ctrlHandle);
                AutoItX.WinActivate(winHandle);
                AutoItX.ControlClick(winHandle, ctrlHandle, "primary", 1, ctrlPos.Width - 160, ctrlPos.Height - 30);
                Thread.Sleep(1000);
                AutoItX.ControlSend(winHandle, ctrlHandle, "{ENTER}");

    Thanks,

    Saranya


    Friday, April 17, 2020 12:33 PM

All replies

  • Hi Saranya Madhusudhan,

    It looks like the option to disable the open or save prompt has been removed from the Internet Explorer browser for a security purpose.

    I found that registry key setting will also not work for disabling the open or save prompt in IE 10 and IE 11 browser.

    So there is no way to disable the open or save prompt.

    You need to use any third party library in your selenium code to automate that popup because Selenium does not has any way to automate that popup.

    Using any third party libarry, you can try to accept the prompt to download the file.

    Regards,

    Deepak  


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 15, 2020 10:40 AM
  • Hi Deepak,

    Thanks for the reply.

    I tried the registry entries you are talking about and yes, they don't work because those entries are no longer used by either the IE or the Windows as they have removed the functionality.

    I tried to use AutoIt to get control of the open or save popup. Since its not a window nor a proper dialog box with title, I am not able to control it through AutoIt. 

    Here is the code I used.

                int isSaveWindowDisplayed = AutoIt.AutoItX.WinActive("[Class:IEFrame]");
                if (isSaveWindowDisplayed == 1)
                {
                    var winHandle = AutoIt.AutoItX.WinGetHandle("[Class:IEFrame]");
                    var ctrlHandle = AutoIt.AutoItX.ControlGetHandle(winHandle, "[ClassNN:DirectUIHWND1]");
                    var ctrlPos = AutoIt.AutoItX.ControlGetPos(winHandle, ctrlHandle);
                    var winPos = AutoIt.AutoItX.WinGetPos(winHandle);
                    AutoIt.AutoItX.ControlClick(winHandle, ctrlHandle, "primary", 1, ctrlPos.Width - 70, ctrlPos.Height - 30);
                    Thread.Sleep(500);
                    AutoIt.AutoItX.ControlSend(winHandle, ctrlHandle, "{enter}");
                }

    I found this code online somewhere and it doesn't work and I am new to this AutoIt.

    I tried clicking on ALT+S combination through Selenium Actions. That doesn't work either. Only CTRL+A works, nothing else works.

    Can you help me with this?

    Thanks,

    Saranya


    Wednesday, April 15, 2020 11:07 AM
  • Hi Saranya Madhusudhan,

    Yes, Autoit code can help you to automate that Save Open popup.

    The Autoit is a third party product and I am not familiar with it.

    Autoit has a forum support. I suggest you raise a question there.

    Autoit forums

    Thank you for your understanding.

    Regards,

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, April 15, 2020 1:39 PM
  • Hi Deepak,

    Thank you for pointing me to the right forum, I have got the logic. 

    I am posting it here if someone needs it.

                var winHandle = AutoItX.WinGetHandle("[Class:IEFrame]");
                var ctrlHandle = AutoItX.ControlGetHandle(winHandle, "[Class:DirectUIHWND]");
                var ctrlPos = AutoItX.ControlGetPos(winHandle, ctrlHandle);
                AutoItX.WinActivate(winHandle);
                AutoItX.ControlClick(winHandle, ctrlHandle, "primary", 1, ctrlPos.Width - 160, ctrlPos.Height - 30);
                Thread.Sleep(1000);
                AutoItX.ControlSend(winHandle, ctrlHandle, "{ENTER}");

    Thanks,

    Saranya


    Friday, April 17, 2020 12:33 PM