Unable to save PDF file opened in browser in webdriver

4,640 views
Skip to first unread message

Amit

unread,
Aug 19, 2012, 11:47:35 AM8/19/12
to seleniu...@googlegroups.com
Hi All,
I am trying to save a pdf file which is opened after clicking on a web link. I am using Action builder to send a combination of of keys (Ctrl+Shift+S) . This is my code? 
 
        try{
            Actions builder = new Actions(driver);
           
            builder.keyDown(Keys.CONTROL);
            builder.keyDown(Keys.SHIFT);
            builder.sendKeys("S");
           
            builder.keyUp(Keys.CONTROL);
            builder.keyUp(Keys.SHIFT);
   
            builder.build().perform();
           
                     
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("ERROR"+e);
        }

But no success achieved. Later i used following autoIt Script to send the same But no luck:-(


AutoIt Script:

WinWait("[Class:MozillaWindowClass]")
WinActivate("[Class:MozillaWindowClass]","")
Send("^+");
Send("{ENTER}")


Can anyone have faced this issue .Please share your experience anyone have something

Thanks in Advance:-)
==========================================================================


Peter Gale

unread,
Aug 19, 2012, 11:55:08 AM8/19/12
to Selenium Users
Please refer to this thread, in particular Mark Collin's link to a comprehensive discussion of the subject and a file downloader class.


Date: Sun, 19 Aug 2012 08:47:35 -0700
From: amit....@impetus.co.in
To: seleniu...@googlegroups.com
Subject: [selenium-users] Unable to save PDF file opened in browser in webdriver
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Xzn6-6ZuwewJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Amit

unread,
Aug 19, 2012, 12:37:10 PM8/19/12
to seleniu...@googlegroups.com
Thanks for your quick reply !!!

As I am new  bee in selenium + java. Peter, it would be more appreciable if you could guide me how to use this Downloader utility by Colin Mark
https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/FileDownloader.java

or if any other work around to solve this?

Peter Gale

unread,
Aug 19, 2012, 12:48:43 PM8/19/12
to Selenium Users
I think I tried explaining how to use it on one thread, though I've never used it myself. You might want to search for that thread, but I'm not going to go though it again, and Mark's notes seemed sufficiently comprehensive for anyone with a basic knowledge of java.

If you're new to java you might want to learn how to use java in itself, which is really a pre-requisite for using any java based api, such the Selenium java bindings. The same goes for other languages. We try to keep the focus on Selenium only issues here, though sometimes have to give a little peripheral support.


Date: Sun, 19 Aug 2012 09:37:10 -0700
From: amit....@impetus.co.in
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Unable to save PDF file opened in browser in webdriver
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kS52heKzpbcJ.

Amit

unread,
Aug 19, 2012, 1:21:17 PM8/19/12
to seleniu...@googlegroups.com
Hi Peter/ Collin,

I found solution to use it from the test class by collin,

Now I am able to save the pdf file at my desired location.

Thanks a ton to you guys for such a downloader utility. Its a very help full:-)


-Amit

Mark Collin

unread,
Aug 20, 2012, 11:07:03 AM8/20/12
to seleniu...@googlegroups.com

Only just seen this, but you probably want to have a read of this:

 

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

 

It has an updated version of the code and also tries to make you question why you are downloading files in the first place, usually you don’t need to.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9In6CPPsqTIJ.

Reply all
Reply to author
Forward
0 new messages