0

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.

5
  • 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 it Commented May 10, 2017 at 13:48
  • 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
    Commented May 10, 2017 at 13:54
  • okay, well you can try click using selenium's JavascriptExceutor to clcik that button element Commented May 10, 2017 at 16:24
  • 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
    Commented May 11, 2017 at 7:37
  • Yes but it can click the button which initiates download Commented May 11, 2017 at 8:13

1 Answer 1

1

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).

1
  • Probably I'll use a fork of PhantomJs that is being developed, called YorksitoJS.
    – p0kero
    Commented May 11, 2017 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.