0

I need to simulate file download on chrome browser and below links points to solutions which is what I'm looking for.

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

https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/FileDownloader.java

I'm not able to use this code as it requires attribute and in my case button has a reactid which triggers a end point call. Please refer to attached screen shot.

Can somebody please tell what changes I need to do to make code in above links work ?

Thanks in advance.

Regards, Vikramenter image description here

vikramvi
  • 3,312
  • 10
  • 45
  • 68

2 Answers2

1

Since you can't get the link of the downloadable file from the html and verify the https status code because in your case - the downloading happens by javascript method

The only way to verify downloading in your case is to actually click the element and verify that the file was downloaded.

You also need to set the capability in ChromeDriver to download to default directory without asking. Chrome Web Driver download files

Community
  • 1
  • 1
Liraz Shay
  • 86
  • 4
1

To be able to download a link to need to find a way to get the link. The best way to do that is to talk to the developer that wrote the code and find out how it works.

Clicking on the button will trigger some sort of JavaScript event, you need to know what that event is so that you can replicate it to get the download link.

Bear in mind that this is probably not a test that's worth performing in Selenium., it's probably a unit test in JavaScript land.

Ardesco
  • 7,281
  • 26
  • 49
  • why is it so hard to bring in unit testing or testing culture in dev world :( This should be first chapter in all of CS curriculum – vikramvi Aug 25 '16 at 14:32