Ask a Question

handle file download in browser

vthomeschoolmom
Super Contributor

handle file download in browser

I saw some related posts on this topic which refer to the SaveFile method of the Window object. A web app does not have a window object in it. At least mine doesn't. ๐Ÿ™‚

 

My application under test presents a user with an option to open or save a file to be downloaded. In my test, I want to save it to ... wherever. Obviously, the different brownsers have different dialogs. Object spy does not see the dialog at all. 

 

What is the best way to handle this in a web app in a manner that is useful for all browsers? THANKS!

18 REPLIES 18

Just a further note on the above:

 

If it is because it requires a desktop license, it comes into play even earlier than when you try to access BrowserWindow methods in script and that may be why I can find it without technically tying up a desktop license.  BrowserWindow(0) is available for me to map in the Object browser right off the bat and I was able to NameMap it:

 

 

 

Browserwindow mapping.JPG

 

This is unfortunaly the extent of what I can assist.  I haven't tried any other means of downloading files yet, sorry.


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

Yes browser window cannot find and windows.

 

TanyaYatskovska
SmartBear Alumni (Retired)

Hi @vthomeschoolmom,

 

Have you seen this sample?

Download a file from the Internet

 

I think only Platform objects are used there.

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



I will check it out. Thanks!

No love.

Sub Test
  Dim strFileURL, strHDLocation, objHTTP, objADOStream, objFSO 
  
  ' Specify the names of the source and destination files
  strFileURL = "http://www.automatedqa.com/file to get"
  strHDLocation = "c:\temp\filename"

I am looking for means to handle the USER INTEFACE within the browser. 

 

TanyaYatskovska
SmartBear Alumni (Retired)

I see. In this case, you will need to work with the Browser's dialogs. I'm not sure if TestComplete has access to them. Usually, browsers blocks iteration with their own dialogs. UI Automation or MSAA would help. However, as far as I remember they are in the Desktop module.

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Is it critical to work with the user interface or is it simply that the popup is getting in the way of your download ?

 

If it's the second option, you could (this is IE only, but could be modified for chrome etc..) change the Default download path for the browser to one you know.  Downloads folder will work fine as well I guess.  Secondly, get rid of the confirmation box that gets displayed when you try and download.  Now you won't get prompted and the file will just show up in your downloads folder.  In everyday use, this is dangerous.  In a controlled environment, it's fine.

 

Something like:

 

https://jwcooney.com/2014/03/31/remove-internet-explorer-open-or-save-popup/ 

 

Disclaimer: I haven't tried or read the article in-depth.  Just suggesting a potential alternative approach


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
TanyaYatskovska
SmartBear Alumni (Retired)

Hi @vthomeschoolmom,

 

Did you find the solution you decided to use?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Not really. Such is the nature of browser apps. I guess I will just cause each browser not to require a prompt for download. I don' t love it. But it is what it is.

cancel
Showing results forย 
Search instead forย 
Did you mean:ย