0
votes

I need to download a pdf file with Selenium. This pdf file is downloaded when a button is clicked. The URL of the file isn't accesible, the button submit a form and the server response directly with the file (without confirm dialog).

I'm using PhantomJS WebDriver (the project is in C#) because the application will be an Azure webapp, so I can't use ChromeDriver or similar. The problem is that PhantomJS can't deal with binary files, so when I simulate the click in the button the app doesn't download anything.

Any ideas??

P.D: Selenium is not only for the pdf download, the project do a lot of scrapping with it.

1
you don't have to interact with file itself just the button; so you just need to click.. am I right? you can use a custom waitAndClick() method which waits for element to be visible, clickable and then uses Actions class to focus the element and click itKushal Bhalaik
Probably I haven't expressed it very well... When the button is clicked, the download is started (when I use, for example, ChromeDriver). But nothing happen when the button is "clicked" with PhantomJS.p0kero
okay, well you can try click using selenium's JavascriptExceutor to clcik that button elementKushal Bhalaik
Thanks for the comments. The problem is that whem Selenium click the button (usin PhantomJS) nothing happen, because it can't handle binary files so it doesn't download the file.p0kero
Yes but it can click the button which initiates downloadKushal Bhalaik

1 Answers

1
votes

If you are using Azure and you are not able to fidn any solution, I would suggest greating a virtual machine with graphical interface so you can run an instance of ChromeDrive (or another one).