How to save PDF file in Cognos Viewer app w/Selenium Webdriver w/Java

125 views
Skip to first unread message

Wanderlust Media

unread,
Sep 18, 2015, 8:51:25 PM9/18/15
to Selenium Users
Step 1: My app creates a PDF report in a new window generated by Cognos Viewer. All of the reports take 1-30 seconds to complete, and I don't know how to wait for a "complete" message.
Step 2: When the report is completed, a "download" icon appears. I would like to save the PDF report to a file with a unique name (right now, all reports in a category can be downloaded with a generic name, but the reports need to be run with different parameters. I cannot seem to reach the download icon with driver.findElement(By.id("download")).click();

The Page Source in the browser looks like it's mostly Javascript. When I use the Inspector I can see the HTML (where I found the id=download). It's not clear to me how the PDF and HTML interact.

I'm running Selenium Webdriver with Java/Eclipse on Windows on Firefox.

Any help is appreciated. Thanks in advance.

Krishnan Mahadevan

unread,
Sep 18, 2015, 9:59:11 PM9/18/15
to Selenium Users
To begin with, you cant really interact with a pdf using Selenium. 

If your pdf is generated at the server side and if you are just resorting to clicking a link which renders the generated pdf in the browser, you could perhaps consider downloading the pdf. You can go through the below two links for learning how to do it.

  1. http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
  2. https://github.com/Ardesco/What-Did-You-Download
If your pdf is actually generated when you click some button or link and then shown then you may have to resort to using some other tools such as AutoIT to get this done.


 

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c7f78be1-f94b-4cf6-b540-d5ebbd6ed3a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages