Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Add ability to download links #95

Open
lukeis opened this issue Mar 2, 2016 · 36 comments
Open

Add ability to download links #95

lukeis opened this issue Mar 2, 2016 · 36 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 95

Every browser provides a 'Save Link As' or 'Save Target As' feature to
download links as files.

Adding the same feature to WebDriver would be especially useful because it
would enable testing of non-HTML output.

For example: dynamically generated PDFs could be tested by downloading them
and then checking their content using e.g. PDFBox.

  WebElement pdfLink = driver.findElement(...);
  File pdfFile = new File("/path/to/output.pdf")
  pdfLink.downloadTo(pdfFile);
  ...

Related forum discussion:
http://groups.google.com/group/webdriver/browse_thread/thread/8d4f1dfbd3d98050

Reported by mirko.nasato on 2008-09-15 11:32:13

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

You could look at the code for Canoo WebTest which supports testing content of PDFs.

I've only used this for links that open in the browser, rather than for downloading

of pdfs, but it worked well. - john@webtest.co.nz

Reported by pipandjohn on 2008-09-16 09:10:53

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I will be glad to see this addressed, at least when Web driver is merged with Selenium.

Reported by tkumarb on 2008-10-07 15:20:34

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I would also like to access resources such as images that are within the browser 
page. the equivellent of htmlunit's HtmlImage.getImageReader()

and not downloading from src image.

Reported by jarosia.hope on 2009-05-11 13:57:36

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'd like this to work with links to arbitrary binary files which return a response
with a header like "Content-Disposition: attachment; filename=foo.bin"

Reported by townxelliot on 2009-06-22 09:22:12

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

It may be possible to extend the WebDriver extension in Firefox to handle different

MIME types.
Some relevant links:
https://developer.mozilla.org/en/Document_Loading_-
_From_Load_Start_to_Finding_a_Handler
https://developer.mozilla.org/En/How_Mozilla_determines_MIME_Types
https://developer.mozilla.org/en/Overview_of_how_downloads_work
http://www.oxymoronical.com/experiments/xpcomref/applications/Firefox/3.5/interfaces/
nsIMIMEService

Reported by eran.mes on 2009-11-24 10:58:44

  • Labels added: GettingInvolved

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by jmleyba on 2010-01-05 01:06:08

  • Labels added: Type-Enhancement
  • Labels removed: Type-Defect

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Note Issue 199 with a simpler sub-requirement that may be easier to implement in the
short-term, and already of use to some, as a starting point...

Reported by michael.vorburger on 2010-01-12 14:49:10

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Yeah this would be a great addition. A current work around is loading the image and
the print screen and chopping it up with imagemagick.

Reported by jamesbachini7 on 2010-09-11 08:43:43

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I will have something for this in a patch this week, specifically for the python bindings.

Reported by antlong on 2010-10-08 00:25:49

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 868 has been merged into this issue.

Reported by antlong on 2010-10-08 00:26:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Patch for python in http://code.google.com/p/selenium/issues/detail?id=872

Reported by antlong on 2010-10-12 17:40:36

  • Labels removed: GettingInvolved

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is there anyone can guide me how to deal with download in IE?
Seems downloadTo method is not ready.
Thanks.

Reported by miracleoyl on 2010-12-10 06:54:00

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

any news on this issue?
This is really blocking and autoit is not always a reliable option/workaround (eg on
remote sessions running it fails sporadically).

Reported by gogomts on 2010-12-22 12:25:39

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is there any workaround if the method is not ready?

Reported by ramapullareddy on 2011-01-31 05:06:30

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

For PDFs, etc. displayed inline in browser or images, etc., anyone try scripting a search
of browser cache for the file? Because the files are saved to cache, you could try
to retrieve a copy from there to do analysis, etc. This would be done with code outside
WebDriver of course.

Also, another workaround beside AutoIt may be to try Sikuli?

Reported by mangaroo on 2011-07-24 05:54:56

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 2430 has been merged into this issue.

Reported by james.h.evans.jr on 2011-09-09 12:47:28

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 2553 has been merged into this issue.

Reported by barancev on 2011-09-28 11:49:16

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by barancev on 2011-10-12 18:05:16

  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I hit this issue recently, I worked around it by simply getting the href attribute that
points to the file and using a webclient api (c#) to download the file direct from
that url. not the same as proving the browser will download it, but close enough.
just about to investigate tools to check pdf content...

Reported by daniel@demigoth.org on 2011-11-25 11:01:55

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 2943 has been merged into this issue.

Reported by barancev on 2011-11-28 09:44:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by jmleyba on 2011-11-29 17:26:08

  • Labels added: Priority-Low
  • Labels removed: Priority-Medium

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 2980 has been merged into this issue.

Reported by james.h.evans.jr on 2011-12-13 20:20:36

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This would be extremely helpful, unless I am missing a simpler workaround. Our web software
has many places where we either upload a file or download a file, and I don't know
how selenium can handle the system dialog from windows. So I just can't test whether
these features work. That's a major drawback.

Reported by theskyband on 2012-11-09 23:26:58

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Code to get around this issue in this blog post:

http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

Reported by fyrespray on 2012-11-19 15:07:15

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

On comment 25, that's in Java. Comment 20 mentions C# equivalent but no code available.
I assume comment 11 has Python equivalent.

If one wants PHP version, see this: https://gist.github.com/3433180

Reported by mangaroo on 2012-11-20 01:59:17

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 4841 has been merged into this issue.

Reported by barancev on 2012-11-29 09:46:37

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 4245 has been merged into this issue.

Reported by barancev on 2012-12-21 05:35:47

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 5004 has been merged into this issue.

Reported by barancev on 2013-01-14 06:29:48

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Any news on this? It would be really useful. I've been looking at converting Java classes
to C#/NET so that I can do something about it, but if I could have it natively it would
be great.

Reported by chromium.bug.reporting on 2013-04-18 11:01:36

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 5696 has been merged into this issue.

Reported by a.u.savchuk on 2013-08-05 18:47:06

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 5992 has been merged into this issue.

Reported by barancev on 2013-11-02 21:05:07

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 6724 has been merged into this issue.

Reported by luke.semerau on 2013-12-14 21:59:02

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I think another approach might be some sort of utility method that can take in a web
element, extract the cookies and auth information used in the request that link will
goto, and return a request object for someone to perform the request using an already
authenticated endpoint.

Reported by SBSquid on 2014-02-11 21:43:10

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 7967 has been merged into this issue.

Reported by barancev on 2014-09-26 14:35:27

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I had to resolve the issue in another way as the target application did detect session
stealing when using the usual method.
See https://github.com/rac2030/SeleniumDownloadHelper 
It's not the nice way but it's doing the job over injected javascript directly in the
context of the original page.

Reported by michel.racic on 2014-10-31 07:28:42

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 17:44:23

  • Labels added: Restrict-AddIssueComment-Commit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant