2

I am trying to confirm the file downloaded from an api. After reviewing the recommendation from How to test download api using karate, my scenario was written like below:

Scenario: GET /project - Export project listing 
Given params { someparam: 'paramvalue' }
When method GET
Then status 200
And match header Content-Disposition == 'attachment;filename="someFile.xlsx"'
And match header Content-Type == 'application/vnd.ms-excel'
And match response == read('data/exported.xlsx')

The first 2 matches pass. However, the last match (comparing the actual file) fails with a binary printout of both files and "reason: not equal".

The file "exported.xlsx" in the comparison was the output of the exact same request done via Postman, so they should match.

Is read() able to handle excel and csv files? Any help would be appreciated.

AyoO
  • 1,204
  • 10
  • 7

1 Answers1

1

As far as I know this should have worked. read('data/exported.xlsx') will return a stream of bytes.

If this is indeed a bug you will do a great service to the community if you follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • This is not a public API, so I'll have to find one to submit this. Will see what I can find. – AyoO Oct 05 '18 at 03:20
  • @AyoolaOgunsola yep I know. my stand is there is an example in the karate-demo that works. maybe you can debug and see what's going on. IMO this is unlikely to be a karate issue. – Peter Thomas Oct 05 '18 at 03:31
  • @PeterThomas I am also facing the same issue while comparing exported (xlsx)file content. I am getting the error:reason: not equal. Let me know how can I help you to replicate? – QualityMatters Dec 19 '18 at 11:48