1

I have a page with 3 links, all PDF files. They all refer to the same directory but to different files in that directory, all of which are pdf files (ending in .pdf). Manually clicking on any of these links opens up the pdf document in a new page. (I guess theoretically the requirement is to download but this seems similar).

Our Java/Selenium "guru" wrote a method executFileDownload() to download a file from a link such as the above, since selenium clicking on the link and trying to manipulate through the file save window or whatever is tricky). This method returns the name of a file to which the file was downloaded.

This method works fine for the first two links. It downloads them fine. For the third link it says it cannot find the data in the http response. For the first two, the mime type is I believe application/pdf but for the third one it is just "" (null or empty). The guy here said there is an empty response.

Now obviously I don't expect you to know what the difference in these files would be, though I can manually click on each link and a correct pdf file opens up. But I thought maybe you might have some suggestions as to why one link might be different from the others, even though they are exactly the same except for the file name, which are all .pdf? I thought maybe the thrid one gets generated automatically so when you open it, originally it is blank. Something like that?

I tried getting the url and opening it and reading from it. All 3 files return 29 blank lines. I think that is probably because they are PDF files and so have no text. When I download the two using the above method and look at the files (which I used PDFBox to extract the text from) they all appear as they should, with all the information (they are user guides).

I am not sure I can, for proprietary reasons, show the executeFileDownload() code. But it uses JSON and checks the response header.

So I guess what I am trying to understand is whether there could be some differences in the way PDF files are sent over http that could cause this discrepancy, or what else I might try?

(This is using Java with Selenium and Eclipse).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.