Download a file protractor test case
Asked Answered
K

1

22

I am writting a protractor test case to download a file which can be of any type.

  • Scenario: Download a file
  • Step 1: Click on the Download Link
  • Step 2: Check whether the file is downloaded or not

How do i check if the file is downloaded correctly or not?

Knar answered 28/11, 2014 at 17:16 Comment(0)
I
28

I was able to achieve download testing with Chrome.

  1. Follow this config setup: https://mcmap.net/q/395766/-protractor-e2e-test-case-for-downloading-pdf-file

  2. Create a function waitFileExists(fileAbsPath) and performs your expectations after the file is completely downloaded: https://mcmap.net/q/395766/-protractor-e2e-test-case-for-downloading-pdf-file

Introductory answered 28/11, 2014 at 17:59 Comment(4)
hi @Leo Gallucci , i changed something to download excel and pdf. It worked for exporting excel file but falsed with pdf. I think "application/pdf" is not enough to set download automatically pdf file. What can I do ?Brandt
@Brandt You need to add the content disposition header for that, see developer.mozilla.org/en-US/docs/Web/HTTP/Headers/…Claudineclaudio
Sample code for an Angular/TypeScript project: gist.github.com/tw3/ef2858f3fe4d224e02eb9ff5dbca2abaImmateriality
Thank you! You saved me hours of investigating.Extricate

© 2022 - 2024 — McMap. All rights reserved.